new 6
++++++
Global class epayworkitemupdates2{
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)
{
returnWorkitemresponse response = new returnWorkitemresponse();
//if((id.length() == 15 || id.length() == 18) && Pattern.matches('^[a-zA-Z0-9]*$', id))
QC_Checklist__c wrkitm = new QC_Checklist__c();
Account Accdetails=new Account();
if((leadlst.wrkitemid != Null && leadlst.wrkitemid !='') &&(leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
wrkitm =[Select id,Opportunity_Merchant_Name__c,Opportunity_Merchant_Name__r.StageName,Type__c,Contract_Status__c,
Reject_Reason__c,Boarding_Source__c from QC_Checklist__c WHERE id = :leadlst.wrkitemid];
system.debug('workitem not null');
} else
if(leadlst.LegalEntityid != Null && leadlst.LegalEntityid != ''){
//Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber=:leadlst.LegalEntityid];
Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber= :leadlst.LegalEntityid];
system.debug('legalEntityId not null');
} else
if((leadlst.wrkitemid == Null && leadlst.wrkitemid == '') && (leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
response.status = 'please Provide legalEntityId or Workitem id to update the workitem';
return response;
}
else
if(wrkitm != Null && leadlst.LegalEntityid == Null ) {
//query the account details
Opportunity Oppdetails2=[Select id,Name,Probability,StageName,AccountId from Opportunity where id=:wrkitm.Opportunity_Merchant_Name__c ];
Account Accdetails2=[select id,name,AccountNumber,Account_Status__c from Account where id=:Oppdetails2.AccountId];
if(wrkitm.Contract_Status__c == 'Complete - 16')
{
wrkitm.Opportunity_Merchant_Name__c=Accdetails2.AccountNumber;
//wrkitm.Type__c=leadlst.wrkitmtype;
wrkitm.Contract_Status__c=leadlst.wrkitmstatus;
// wrkitm.Reject_Reason__c=;
update wrkitm;
Oppdetails2.StageName='Closed Won';
update Oppdetails2;
Accdetails2.Account_Status__c='Active';
update Accdetails2;
response.status = 'updated workitem';
response.Wrkitmid = wrkitm.id;
}else if(wrkitm.Contract_Status__c == 'Resubmit') //instead of referal we use resubmit
{
wrkitm.Contract_Status__c='Resubmit';
update wrkitm;
//noified to CR ops team
response.status = 'workitem status is refereal';
}
}
else
if((Accdetails.AccountNumber !=null && Accdetails.AccountNumber!='') && (leadlst.wrkitemid ==''&& leadlst.wrkitemid == null) )
{
system.debug('account query results'+Accdetails);
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
//string wokitmid=leadlst.wrkitemid;
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
system.debug('Accdetails results'+Accdetails);
Opportunity Oppdetails=[Select id,Name,Probability,StageName,AccountId from Opportunity where Account.AccountNumber=:leadlst.LegalEntityid];
RecordType rType = [Select id,Name from RecordType
where Name ='QcChecklist_ePayablePortal'
AND SobjectType= 'QC_Checklist__c'];
system.debug('opp query results'+Oppdetails);
if(Accdetails.Account_Status__c == 'Active')
{
QC_Checklist__c workitem1 = new QC_Checklist__c();
// workitem1.Opportunity_Merchant_Name__c = leadlst.LegalEntityid;
workitem1.Opportunity_Merchant_Name__c = '0061b000002OuXg';
workitem1.RecordTypeId= rType.Id;
workitem1.QC_Rep__c=UserInfo.getUserId();
//workitem1.Type__c=leadlst.wrkitmtype;
workitem1.Contract_Status__c=leadlst.wrkitmstatus;
//workitem1.Reject_Reason__c=;
//workitem1.Boarding_Source__c=leadlst.Reasoncode;
insert workitem1;
// response.legalEntityId =leadlst.LegalEntityid;
response.Wrkitmid =workitem1.id;
System.debug('new workitem opp name'+workitem1.Opportunity_Merchant_Name__c);
System.debug('new workitemid'+workitem1.id);
System.debug('new workitem assigned user'+workitem1.QC_Rep__c);
}else if(Accdetails.Account_Status__c == 'Sold'){ //instead of service i given sold because value is not in dev
RecordType rType2 = [Select id,Name from RecordType where Name ='Case_ePayablePortal' AND SobjectType= 'Case'];
case casedetails=[select id,AccountId,Status,Type,Recordtype.name from case where Account.AccountNumber=:leadlst.LegalEntityid and Recordtype.name='Case_ePayablePortal' limit 1 ];
System.debug('casedetails query'+casedetails);
if(casedetails.id == Null){
case c1=new case();
c1.AccountId=Accdetails.id;
c1.RecordTypeId= rType2.Id;
c1.Status='New';
//c1.Type=leadlst.wrkitmtype;
insert c1;
response.Status ='Case created';
//response.Wrkitmid =c1.id;
}else if(casedetails != Null){
casedetails.Status='In Progress';
//casedetails.Type=leadlst.wrkitmtype;
update casedetails;
response.Status ='Case Updated';
}
}
}else
if(Accdetails == Null && wrkitm == Null)
{
response.status = 'please Provide valid legalEntityId or Workitem id to update the workitem';
}
return response;
}
}
+++++++++++++
new 8+++
+++++++++++++
Global class epayworkitemupdates2{
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)
{
returnWorkitemresponse response = new returnWorkitemresponse();
//if((id.length() == 15 || id.length() == 18) && Pattern.matches('^[a-zA-Z0-9]*$', id))
QC_Checklist__c wrkitm = new QC_Checklist__c();
Account Accdetails=new Account();
if((leadlst.wrkitemid != Null && leadlst.wrkitemid !='') &&(leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
wrkitm =[Select id,Opportunity_Merchant_Name__c,Opportunity_Merchant_Name__r.StageName,Type__c,Contract_Status__c,
Reject_Reason__c,Boarding_Source__c from QC_Checklist__c WHERE id = :leadlst.wrkitemid];
system.debug('workitem not null');
} else
if(leadlst.LegalEntityid != Null && leadlst.LegalEntityid != ''){
//Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber=:leadlst.LegalEntityid];
Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber= :leadlst.LegalEntityid];
system.debug('legalEntityId not null');
} else {
if((leadlst.wrkitemid == Null && leadlst.wrkitemid == '') && (leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
response.status = 'please Provide legalEntityId or Workitem id to update the workitem';
//return response;
}
}
if(wrkitm != Null && wrkitm !='') {
//query the account details
Opportunity Oppdetails2=[Select id,Name,Probability,StageName,AccountId from Opportunity where id=:wrkitm.Opportunity_Merchant_Name__c ];
Account Accdetails2=[select id,name,AccountNumber,Account_Status__c from Account where id=:Oppdetails2.AccountId];
if(wrkitm.Contract_Status__c == 'Complete - 16')
{
wrkitm.Opportunity_Merchant_Name__c=Accdetails2.AccountNumber;
//wrkitm.Type__c=leadlst.wrkitmtype;
wrkitm.Contract_Status__c=leadlst.wrkitmstatus;
// wrkitm.Reject_Reason__c=;
update wrkitm;
Oppdetails2.StageName='Closed Won';
update Oppdetails2;
Accdetails2.Account_Status__c='Active';
update Accdetails2;
response.status = 'updated workitem';
response.Wrkitmid = wrkitm.id;
}else if(wrkitm.Contract_Status__c == 'Resubmit') //instead of referal we use resubmit
{
wrkitm.Contract_Status__c='Resubmit';
update wrkitm;
//noified to CR ops team
response.status = 'workitem status is refereal';
}
else
{
response.status = 'workitem status not active or referal';
}
}
else
if((Accdetails== null && Accdetails =='')
//if((Accdetails.AccountNumber !=null && Accdetails.AccountNumber!='') && (leadlst.wrkitemid ==''&& leadlst.wrkitemid == null) )
{
system.debug('account query results'+Accdetails);
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
//string wokitmid=leadlst.wrkitemid;
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
system.debug('Accdetails results'+Accdetails);
Opportunity Oppdetails=[Select id,Name,Probability,StageName,AccountId from Opportunity where Account.AccountNumber=:leadlst.LegalEntityid];
RecordType rType = [Select id,Name from RecordType
where Name ='QcChecklist_ePayablePortal'
AND SobjectType= 'QC_Checklist__c'];
system.debug('opp query results'+Oppdetails);
if(Accdetails.Account_Status__c == 'Active')
{
QC_Checklist__c workitem1 = new QC_Checklist__c();
// workitem1.Opportunity_Merchant_Name__c = leadlst.LegalEntityid;
workitem1.Opportunity_Merchant_Name__c = '0061b000002OuXg';
workitem1.RecordTypeId= rType.Id;
workitem1.QC_Rep__c=UserInfo.getUserId();
//workitem1.Type__c=leadlst.wrkitmtype;
workitem1.Contract_Status__c=leadlst.wrkitmstatus;
//workitem1.Reject_Reason__c=;
//workitem1.Boarding_Source__c=leadlst.Reasoncode;
insert workitem1;
// response.legalEntityId =leadlst.LegalEntityid;
response.Wrkitmid =workitem1.id;
System.debug('new workitem opp name'+workitem1.Opportunity_Merchant_Name__c);
System.debug('new workitemid'+workitem1.id);
System.debug('new workitem assigned user'+workitem1.QC_Rep__c);
}else if(Accdetails.Account_Status__c == 'Sold'){ //instead of service i given sold because value is not in dev
RecordType rType2 = [Select id,Name from RecordType where Name ='Case_ePayablePortal' AND SobjectType= 'Case'];
case casedetails=[select id,AccountId,Status,Type,Recordtype.name from case where Account.AccountNumber=:leadlst.LegalEntityid and Recordtype.name='Case_ePayablePortal' limit 1 ];
System.debug('casedetails query'+casedetails);
if(casedetails != Null){
casedetails.Status='In Progress';
//casedetails.Type=leadlst.wrkitmtype;
update casedetails;
response.Status ='Case Updated';
}
else {
case c1=new case();
c1.AccountId=Accdetails.id;
c1.RecordTypeId= rType2.Id;
c1.Status='New';
//c1.Type=leadlst.wrkitmtype;
insert c1;
response.Status ='Case created';
//response.Wrkitmid =c1.id;
}
}
}else
//
{
if(Accdetails == Null && wrkitm == Null){
response.status = 'please Provide valid legalEntityId or Workitem id to update the workitem';
}
}
return response;
}
}
++++++
Global class epayworkitemupdates2{
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)
{
returnWorkitemresponse response = new returnWorkitemresponse();
//if((id.length() == 15 || id.length() == 18) && Pattern.matches('^[a-zA-Z0-9]*$', id))
QC_Checklist__c wrkitm = new QC_Checklist__c();
Account Accdetails=new Account();
if((leadlst.wrkitemid != Null && leadlst.wrkitemid !='') &&(leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
wrkitm =[Select id,Opportunity_Merchant_Name__c,Opportunity_Merchant_Name__r.StageName,Type__c,Contract_Status__c,
Reject_Reason__c,Boarding_Source__c from QC_Checklist__c WHERE id = :leadlst.wrkitemid];
system.debug('workitem not null');
} else
if(leadlst.LegalEntityid != Null && leadlst.LegalEntityid != ''){
//Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber=:leadlst.LegalEntityid];
Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber= :leadlst.LegalEntityid];
system.debug('legalEntityId not null');
} else
if((leadlst.wrkitemid == Null && leadlst.wrkitemid == '') && (leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
response.status = 'please Provide legalEntityId or Workitem id to update the workitem';
return response;
}
else
if(wrkitm != Null && leadlst.LegalEntityid == Null ) {
//query the account details
Opportunity Oppdetails2=[Select id,Name,Probability,StageName,AccountId from Opportunity where id=:wrkitm.Opportunity_Merchant_Name__c ];
Account Accdetails2=[select id,name,AccountNumber,Account_Status__c from Account where id=:Oppdetails2.AccountId];
if(wrkitm.Contract_Status__c == 'Complete - 16')
{
wrkitm.Opportunity_Merchant_Name__c=Accdetails2.AccountNumber;
//wrkitm.Type__c=leadlst.wrkitmtype;
wrkitm.Contract_Status__c=leadlst.wrkitmstatus;
// wrkitm.Reject_Reason__c=;
update wrkitm;
Oppdetails2.StageName='Closed Won';
update Oppdetails2;
Accdetails2.Account_Status__c='Active';
update Accdetails2;
response.status = 'updated workitem';
response.Wrkitmid = wrkitm.id;
}else if(wrkitm.Contract_Status__c == 'Resubmit') //instead of referal we use resubmit
{
wrkitm.Contract_Status__c='Resubmit';
update wrkitm;
//noified to CR ops team
response.status = 'workitem status is refereal';
}
}
else
if((Accdetails.AccountNumber !=null && Accdetails.AccountNumber!='') && (leadlst.wrkitemid ==''&& leadlst.wrkitemid == null) )
{
system.debug('account query results'+Accdetails);
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
//string wokitmid=leadlst.wrkitemid;
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
system.debug('Accdetails results'+Accdetails);
Opportunity Oppdetails=[Select id,Name,Probability,StageName,AccountId from Opportunity where Account.AccountNumber=:leadlst.LegalEntityid];
RecordType rType = [Select id,Name from RecordType
where Name ='QcChecklist_ePayablePortal'
AND SobjectType= 'QC_Checklist__c'];
system.debug('opp query results'+Oppdetails);
if(Accdetails.Account_Status__c == 'Active')
{
QC_Checklist__c workitem1 = new QC_Checklist__c();
// workitem1.Opportunity_Merchant_Name__c = leadlst.LegalEntityid;
workitem1.Opportunity_Merchant_Name__c = '0061b000002OuXg';
workitem1.RecordTypeId= rType.Id;
workitem1.QC_Rep__c=UserInfo.getUserId();
//workitem1.Type__c=leadlst.wrkitmtype;
workitem1.Contract_Status__c=leadlst.wrkitmstatus;
//workitem1.Reject_Reason__c=;
//workitem1.Boarding_Source__c=leadlst.Reasoncode;
insert workitem1;
// response.legalEntityId =leadlst.LegalEntityid;
response.Wrkitmid =workitem1.id;
System.debug('new workitem opp name'+workitem1.Opportunity_Merchant_Name__c);
System.debug('new workitemid'+workitem1.id);
System.debug('new workitem assigned user'+workitem1.QC_Rep__c);
}else if(Accdetails.Account_Status__c == 'Sold'){ //instead of service i given sold because value is not in dev
RecordType rType2 = [Select id,Name from RecordType where Name ='Case_ePayablePortal' AND SobjectType= 'Case'];
case casedetails=[select id,AccountId,Status,Type,Recordtype.name from case where Account.AccountNumber=:leadlst.LegalEntityid and Recordtype.name='Case_ePayablePortal' limit 1 ];
System.debug('casedetails query'+casedetails);
if(casedetails.id == Null){
case c1=new case();
c1.AccountId=Accdetails.id;
c1.RecordTypeId= rType2.Id;
c1.Status='New';
//c1.Type=leadlst.wrkitmtype;
insert c1;
response.Status ='Case created';
//response.Wrkitmid =c1.id;
}else if(casedetails != Null){
casedetails.Status='In Progress';
//casedetails.Type=leadlst.wrkitmtype;
update casedetails;
response.Status ='Case Updated';
}
}
}else
if(Accdetails == Null && wrkitm == Null)
{
response.status = 'please Provide valid legalEntityId or Workitem id to update the workitem';
}
return response;
}
}
+++++++++++++
new 8+++
+++++++++++++
Global class epayworkitemupdates2{
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)
{
returnWorkitemresponse response = new returnWorkitemresponse();
//if((id.length() == 15 || id.length() == 18) && Pattern.matches('^[a-zA-Z0-9]*$', id))
QC_Checklist__c wrkitm = new QC_Checklist__c();
Account Accdetails=new Account();
if((leadlst.wrkitemid != Null && leadlst.wrkitemid !='') &&(leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
wrkitm =[Select id,Opportunity_Merchant_Name__c,Opportunity_Merchant_Name__r.StageName,Type__c,Contract_Status__c,
Reject_Reason__c,Boarding_Source__c from QC_Checklist__c WHERE id = :leadlst.wrkitemid];
system.debug('workitem not null');
} else
if(leadlst.LegalEntityid != Null && leadlst.LegalEntityid != ''){
//Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber=:leadlst.LegalEntityid];
Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber= :leadlst.LegalEntityid];
system.debug('legalEntityId not null');
} else {
if((leadlst.wrkitemid == Null && leadlst.wrkitemid == '') && (leadlst.LegalEntityid == Null && leadlst.LegalEntityid == ''))
{
response.status = 'please Provide legalEntityId or Workitem id to update the workitem';
//return response;
}
}
if(wrkitm != Null && wrkitm !='') {
//query the account details
Opportunity Oppdetails2=[Select id,Name,Probability,StageName,AccountId from Opportunity where id=:wrkitm.Opportunity_Merchant_Name__c ];
Account Accdetails2=[select id,name,AccountNumber,Account_Status__c from Account where id=:Oppdetails2.AccountId];
if(wrkitm.Contract_Status__c == 'Complete - 16')
{
wrkitm.Opportunity_Merchant_Name__c=Accdetails2.AccountNumber;
//wrkitm.Type__c=leadlst.wrkitmtype;
wrkitm.Contract_Status__c=leadlst.wrkitmstatus;
// wrkitm.Reject_Reason__c=;
update wrkitm;
Oppdetails2.StageName='Closed Won';
update Oppdetails2;
Accdetails2.Account_Status__c='Active';
update Accdetails2;
response.status = 'updated workitem';
response.Wrkitmid = wrkitm.id;
}else if(wrkitm.Contract_Status__c == 'Resubmit') //instead of referal we use resubmit
{
wrkitm.Contract_Status__c='Resubmit';
update wrkitm;
//noified to CR ops team
response.status = 'workitem status is refereal';
}
else
{
response.status = 'workitem status not active or referal';
}
}
else
if((Accdetails== null && Accdetails =='')
//if((Accdetails.AccountNumber !=null && Accdetails.AccountNumber!='') && (leadlst.wrkitemid ==''&& leadlst.wrkitemid == null) )
{
system.debug('account query results'+Accdetails);
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
//string wokitmid=leadlst.wrkitemid;
system.debug('leadlst wrktmd results'+leadlst.wrkitemid);
system.debug('Accdetails results'+Accdetails);
Opportunity Oppdetails=[Select id,Name,Probability,StageName,AccountId from Opportunity where Account.AccountNumber=:leadlst.LegalEntityid];
RecordType rType = [Select id,Name from RecordType
where Name ='QcChecklist_ePayablePortal'
AND SobjectType= 'QC_Checklist__c'];
system.debug('opp query results'+Oppdetails);
if(Accdetails.Account_Status__c == 'Active')
{
QC_Checklist__c workitem1 = new QC_Checklist__c();
// workitem1.Opportunity_Merchant_Name__c = leadlst.LegalEntityid;
workitem1.Opportunity_Merchant_Name__c = '0061b000002OuXg';
workitem1.RecordTypeId= rType.Id;
workitem1.QC_Rep__c=UserInfo.getUserId();
//workitem1.Type__c=leadlst.wrkitmtype;
workitem1.Contract_Status__c=leadlst.wrkitmstatus;
//workitem1.Reject_Reason__c=;
//workitem1.Boarding_Source__c=leadlst.Reasoncode;
insert workitem1;
// response.legalEntityId =leadlst.LegalEntityid;
response.Wrkitmid =workitem1.id;
System.debug('new workitem opp name'+workitem1.Opportunity_Merchant_Name__c);
System.debug('new workitemid'+workitem1.id);
System.debug('new workitem assigned user'+workitem1.QC_Rep__c);
}else if(Accdetails.Account_Status__c == 'Sold'){ //instead of service i given sold because value is not in dev
RecordType rType2 = [Select id,Name from RecordType where Name ='Case_ePayablePortal' AND SobjectType= 'Case'];
case casedetails=[select id,AccountId,Status,Type,Recordtype.name from case where Account.AccountNumber=:leadlst.LegalEntityid and Recordtype.name='Case_ePayablePortal' limit 1 ];
System.debug('casedetails query'+casedetails);
if(casedetails != Null){
casedetails.Status='In Progress';
//casedetails.Type=leadlst.wrkitmtype;
update casedetails;
response.Status ='Case Updated';
}
else {
case c1=new case();
c1.AccountId=Accdetails.id;
c1.RecordTypeId= rType2.Id;
c1.Status='New';
//c1.Type=leadlst.wrkitmtype;
insert c1;
response.Status ='Case created';
//response.Wrkitmid =c1.id;
}
}
}else
//
{
if(Accdetails == Null && wrkitm == Null){
response.status = 'please Provide valid legalEntityId or Workitem id to update the workitem';
}
}
return response;
}
}
No comments:
Post a Comment