Global class Workitemupdates{
global class workitemdata
{//Input from portal to create/update workitem information in sfdc
webservice String LegalEntityid;
webservice String oppstage;
webservice String accstatus;
webservice String wrkitmstatus;
webservice String wrkitmtype;
webservice String Reasoncode;
webservice String wrkitemid;
}
global class returnWorkitemresponse
{ // response from SFDC to portal with created/updated record details.
webservice String legalEntityId;
webservice String Wrkitmid;
webservice String Status;
}
webservice static returnWorkitemresponse createupdateworkitems(workitemdata leadlst)
{ // method to load lead data/convert leads and return response
List<returnWorkitemresponse> response = new List<returnWorkitemresponse>();
Account Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber=leadlst.LegalEntityid];
Opportunity Oppdetails=[Select id,Name,Probability,StageName,AccountId from Opportunity where Account.AccountNumber==leadlst.LegalEntityid ];
QC_Checklist__c wrkitm=[Select Opportunity_Merchant_Name__c,Type__c,Contract_Status__c,Reject_Reason__c,Boarding_Source__c from QC_Checklist__c where relationship.opportunityid=Oppdetails.id];
if(leadlst.wrkitemid='null'){
//workitem creation
QC_Checklist__c workitem1 = new QC_Checklist__c();
workitem1.Opportunity_Merchant_Name__c=leadlst.LegalEntityid;
workitem1.Type__c=leadlst.wrkitmtype;
workitem1.Contract_Status__c=leadlst.wrkitmstatus;
workitem1.Reject_Reason__c=;//doubt
workitem1.Boarding_Source__c=leadlst.Reasoncode;
insert workitem1;
}else if(Accdetails.Account_Status__c = 'Application')
{
// QC_Checklist__c wrkitm=[Select Opportunity_Merchant_Name__c,Type__c,Contract_Status__c,Reject_Reason__c,Boarding_Source__c from QC_Checklist__c where relationship.opportunityid=Oppdetails.id];
//update workitem details
if(wrkitm.Contract_Status__c='complete'){
wrkitm.Opportunity_Merchant_Name__c=leadlst.LegalEntityid;
wrkitm.Type__c=leadlst.wrkitmtype;
wrkitm.Contract_Status__c=leadlst.wrkitmstatus;
wrkitm.Reject_Reason__c=;//doubt
update wrkitm;
Oppdetails.StageName='Closed Won';
update Oppdetails;
Accdetails.Account_Status__c='Active';
}else if(wrkitm.Contract_Status__c='Referal'){
wrkitm.Contract_Status__c='Referal';
update wrkitm;
//noified to CR ops team
}
}else if(Accdetails.Account_Status__c = 'Active')
{
case c1=new case();
c1.Account=Accdetails.id;
c1.Status=leadlst.wrkitmstatus;
c1.Type=leadlst.wrkitmtype;
insert c1;
}else if(Accdetails.Account_Status__c = 'Service')
{
case c1=new case();
c1.Account=Accdetails.id;
c1.Status=leadlst.wrkitmstatus;
c1.Type=leadlst.wrkitmtype;
insert c1;
}
return returnWorkitemresponse;
}
}
global class workitemdata
{//Input from portal to create/update workitem information in sfdc
webservice String LegalEntityid;
webservice String oppstage;
webservice String accstatus;
webservice String wrkitmstatus;
webservice String wrkitmtype;
webservice String Reasoncode;
webservice String wrkitemid;
}
global class returnWorkitemresponse
{ // response from SFDC to portal with created/updated record details.
webservice String legalEntityId;
webservice String Wrkitmid;
webservice String Status;
}
webservice static returnWorkitemresponse createupdateworkitems(workitemdata leadlst)
{ // method to load lead data/convert leads and return response
List<returnWorkitemresponse> response = new List<returnWorkitemresponse>();
Account Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber=leadlst.LegalEntityid];
Opportunity Oppdetails=[Select id,Name,Probability,StageName,AccountId from Opportunity where Account.AccountNumber==leadlst.LegalEntityid ];
QC_Checklist__c wrkitm=[Select Opportunity_Merchant_Name__c,Type__c,Contract_Status__c,Reject_Reason__c,Boarding_Source__c from QC_Checklist__c where relationship.opportunityid=Oppdetails.id];
if(leadlst.wrkitemid='null'){
//workitem creation
QC_Checklist__c workitem1 = new QC_Checklist__c();
workitem1.Opportunity_Merchant_Name__c=leadlst.LegalEntityid;
workitem1.Type__c=leadlst.wrkitmtype;
workitem1.Contract_Status__c=leadlst.wrkitmstatus;
workitem1.Reject_Reason__c=;//doubt
workitem1.Boarding_Source__c=leadlst.Reasoncode;
insert workitem1;
}else if(Accdetails.Account_Status__c = 'Application')
{
// QC_Checklist__c wrkitm=[Select Opportunity_Merchant_Name__c,Type__c,Contract_Status__c,Reject_Reason__c,Boarding_Source__c from QC_Checklist__c where relationship.opportunityid=Oppdetails.id];
//update workitem details
if(wrkitm.Contract_Status__c='complete'){
wrkitm.Opportunity_Merchant_Name__c=leadlst.LegalEntityid;
wrkitm.Type__c=leadlst.wrkitmtype;
wrkitm.Contract_Status__c=leadlst.wrkitmstatus;
wrkitm.Reject_Reason__c=;//doubt
update wrkitm;
Oppdetails.StageName='Closed Won';
update Oppdetails;
Accdetails.Account_Status__c='Active';
}else if(wrkitm.Contract_Status__c='Referal'){
wrkitm.Contract_Status__c='Referal';
update wrkitm;
//noified to CR ops team
}
}else if(Accdetails.Account_Status__c = 'Active')
{
case c1=new case();
c1.Account=Accdetails.id;
c1.Status=leadlst.wrkitmstatus;
c1.Type=leadlst.wrkitmtype;
insert c1;
}else if(Accdetails.Account_Status__c = 'Service')
{
case c1=new case();
c1.Account=Accdetails.id;
c1.Status=leadlst.wrkitmstatus;
c1.Type=leadlst.wrkitmtype;
insert c1;
}
return returnWorkitemresponse;
}
}