We already have the method invoke Callout () which is using to send data from Salesforce to the external system (SFDC to SAP/SAP-PI) through Interface outbound. Through this new feature, we are able to return the result as JSON, XML, List<Map<String, String>>. This feature is implemented only for SAP, SOAP and Rest adapters.
This is Calls API Syntax #
CalloutResponse response=IServices.invokeCallout2(String integrationName, String interfaceName, String[] ids, String mode, CallOutControl outBoundControl)
Response could be text of JSON, XML, List<Map<String,String>> based on given flag parameters in CallOutControl and Apex of each adapter handle setting when execute callout.
NOTE: Getting a real-time response is only in mode SYNC.
Input Parameters:
- integrationName: Integration Name
- interfaceName: Interface name
- ids: Collection of sObject id
- mode: BATCH,
CallOutControl | Flag | CalloutResponse (Attributes) | SAP | SAP-PI | SAP-R/3 | SFDC2SAPPI | SOAP | REST | |
returnJSONComplete | true | String payloadJSON | no | no | no | no | yes | yes | |
return XML | true | String payloadXML | no | no | no | yes | yes | yes | |
returnListRecord | true | List<Map<String,String>> records | yes | yes | yes | yes | yes | yes | |
returnIMessages | true | no | no | no | no | no | no | ||
actionDoIntegrate | false | Does not process interface invoke call In/Out | |||||||
actionDoMapping | true | Does nothing with this flag | |||||||
isCreateMessage | false | Does not upsert message only in mode SYNC, Otherwis,e message will upsert. |
Follow the use case to use batch mode in callout2:
Step1: Create Adapter:
- we are using SFDC2SAPPI adapter for outbound processing.
Step2: Create Integration and Outbound Interface:
- Create Integration. Refer Link: (How to create Integration?)
- Create Outbound Interface. (How to create Interface?)
[aux_code language=”javascript” theme=”tomorrow” title=”” extra_classes=””]
skyvvasolutions.CallOutControl c=new skyvvasolutions.CallOutControl();
c.returnxml=true;
c.returnListRecord=true;
c.iscreatemessage=true;
List<String> lId = new List<String>();
for(Account a : [SELECT Id FROM Account]){
lId.add(a.Id);
}
skyvvasolutions.IServices.invokeCallout2(‘Shweta’,’Batch mode’,lId, ‘BATCH’, c);
[/aux_code]
Response type in debug:
1 XML
>>XML: <SOAP:Envelope xmlns:SOAP=’http://schemas.xmlsoap.org/soap/envelope/’><SOAP:Header/><SOAP:Body><ns1:ISTRUCTURE_Account xmlns:ns1=’http://soap.sforce.com/schemas/class/skyvvasolutions/IServices’><Account><MESSAGE>Internal error: Field “language” in structure PI_PERSONALDATA is empty</MESSAGE><Id>00190000004ZlxZAAS</Id><ERP_DEBTOR_ID__c/></Account></ns1:ISTRUCTURE_Account></SOAP:Body></SOAP:Envelope>
2 List of Map
>>>List of Map:({ERP_DEBTOR_ID__c=, Id=00190000004ZlxZAAS, MESSAGE=Internal error: Field “language” in structure PI_PERSONALDATA is empty})