Tutorials

  1. Home
  2. Docs
  3. Tutorials
  4. 68. Different ways to add custom logic for the inbound processing.
  5. 68.1 How to implement custom inbound processing with apex class by old way?

68.1 How to implement custom inbound processing with apex class by old way?

Learning Objective:

After completing this unit, you’ll be able to:

  • Describe custom apex class.
  • Comfortably use the apex class to implement the custom processing integration.

Introduction

We can implement custom inbound processing with apex by two ways.

what is Custom Processing Apex Class with old way?

We always response to give back the message type structure which contain the Salesforce Id and SKYVVA message Id. Customer need to write the complete code for all processing steps

Basic Processing Steps:


Message   ->  Workflow   ->   Mapping   ->  Operation

 

Advantage

We can the fields as we have structured data.

Disadvantage

Customer need to write the complete code for all processing all steps.

 How to implement custom inbound processing with apex class:

To extend some functions of integrate inbound processing extends skyvvasolutions.IProcessCustomAbs and implements skyvvasolutions.GisOdbgIntegration.IProcess

 

Methods are order process integration of custom processing and could be overridden if required

  • void init(String interfaceId) – Select interface based on interfaceId, It can be optional.
  • void doMap(skyvvasolutions.IServicesUtil.IMessageResult iResult) – Manage apex mapping data available in iResult which order list of skvva messages and list Map<String,String> data and handling logic could be applied here.
  • List<skyvvasolutions.IServicesUtil.UpsertResult2> upsert2() – DML operation, upert business record and update status of message based on result of upsert business record (ie. Upsert Account).

 

follow the given steps to use apex class:

Step1: Create apex class

  • Go to set up
  • Search for apex class in quick search box
  • Click on new button

Warning
“Custom Processing Class”: provide full name of your custom processing class (including namespace if any). Format: [namespace.]classname eg: namespaceX.ClassX (if there is namespace in the salesforce instance) or ClassX (if no namespace)

 

The bellow is example of custom processing inbound and some methods should be overridden:

  • global override void init(String interfaceId)
  • global override void doMap(skyvvasolutions.IServicesUtil.IMessageResult iResult)
  • global override List<skyvvasolutions.IServicesUtil.UpsertResult2> upsert2()

 

Example1:


global with sharing class SKYVVA_CustomIntegration
extends skyvvasolutions.IProcessCustomAbs
implements skyvvasolutions.GisOdbgIntegration.IProcess
{
private List<Contact> lc=new List<Contact>();
global override void doMap(skyvvasolutions.IServicesUtil.IMessageResult iResult){
//Assign value of param to its property inherited from the parent
this.iResult=iResult;
//Map data in iResult to your salesforce sObject
for(integer i=0;i<iResult.listMessage.size();i++){

//Data from SAP
Map<String,String> mapRecord =iResult.listMapRecord.get(i);
System.debug(‘mapRecord :: ‘ +mapRecord);
//
Contact c=new Contact();
c.LastName = mapRecord.get(‘lastname’);
lc.add(c);
}
}

global override List<skyvvasolutions.IServicesUtil.UpsertResult2> upsert2(){

//upsert records
Database.UpsertResult[] results=Database.upsert(lc,false);

for(Integer i=0;i<results.size();i++){

Database.UpsertResult rs=results[i];

iResult.listMessage[i].skyvvasolutions__Status__c = ‘Pending’;
iResult.listMessage[i].skyvvasolutions__Modification_Date__c = System.now();

if(rs.isSuccess()){

iResult.listMessage[i].skyvvasolutions__Status__c = ‘Completed’;
//iResult.listMessage[i].skyvvasolutions__Related_To__c = rs[i].getId();

//Recrod is create
if(rs.isCreated()) {
iResult.listMessage[i].skyvvasolutions__Comment__c = ‘Creation Record…’;
}
else {
iResult.listMessage[i].skyvvasolutions__Comment__c =’Modification Record…’;
}
}
else{
iResult.listMessage[i].skyvvasolutions__Status__c = ‘Failed’;
String errDsc=”;
for( Database.Error err:rs.getErrors()){
errDsc+=err.getMessage()+’ ‘;
}
System.debug(‘errDsc :: ‘ +errDsc);
iResult.listMessage[i].skyvvasolutions__Comment__c =errDsc;
}
}//end for

update iResult.listMessage;

return null;
}

}global with sharing class SKYVVA_CustomIntegration
extends skyvvasolutions.IProcessCustomAbs
implements skyvvasolutions.GisOdbgIntegration.IProcess
{
private List<Contact> lc=new List<Contact>();
global override void doMap(skyvvasolutions.IServicesUtil.IMessageResult iResult){
//Assign value of param to its property inherited from the parent
this.iResult=iResult;
//Map data in iResult to your salesforce sObject
for(integer i=0;i<iResult.listMessage.size();i++){

//Data from SAP
Map<String,String> mapRecord =iResult.listMapRecord.get(i);
System.debug(‘mapRecord :: ‘ +mapRecord);
//
Contact c=new Contact();
c.LastName = mapRecord.get(‘lastname’);
lc.add(c);
}
}

global override List<skyvvasolutions.IServicesUtil.UpsertResult2> upsert2(){

//upsert records
Database.UpsertResult[] results=Database.upsert(lc,false);

for(Integer i=0;i<results.size();i++){

Database.UpsertResult rs=results[i];

iResult.listMessage[i].skyvvasolutions__Status__c = ‘Pending’;
iResult.listMessage[i].skyvvasolutions__Modification_Date__c = System.now();

if(rs.isSuccess()){

iResult.listMessage[i].skyvvasolutions__Status__c = ‘Completed’;
//iResult.listMessage[i].skyvvasolutions__Related_To__c = rs[i].getId();

//Recrod is create
if(rs.isCreated()) {
iResult.listMessage[i].skyvvasolutions__Comment__c = ‘Creation Record…’;
}
else {
iResult.listMessage[i].skyvvasolutions__Comment__c =’Modification Record…’;
}
}
else{
iResult.listMessage[i].skyvvasolutions__Status__c = ‘Failed’;
String errDsc=”;
for( Database.Error err:rs.getErrors()){
errDsc+=err.getMessage()+’ ‘;
}
System.debug(‘errDsc :: ‘ +errDsc);
iResult.listMessage[i].skyvvasolutions__Comment__c =errDsc;
}
}//end for

update iResult.listMessage;

return null;
}

}

Step 2: Create Integration

Step3 : Create Interface

  • Go to integration
  • select interface tab and click on new Interface button.

  • Scroll down the page to Runtime Configuration- general section.
  • Check custom processing flag
  • Select custom processing class. Here class is SKYVva_CustomIntegration

Note
“Custom Processing” checkbox: indicates if the interface uses the custom-processing implementation

 

Step4 : Do mapping.

  • Click on Open mapping button.
  • Map the field which we add in class.

Step5: upload data manually

  • go to integration detail page.
  • click on manual load link
  • upload file.

Step7: Check result on message board

You can not see related to link here to check detail as this interface is used custom processing.

Step8 ; Check uploaded record and its details on dev console.

  • Go to setup
  • Go to dev console
  • Apply query on contact object

Was this article helpful to you? Yes No

How can we help?