07-01-2017 06:18 AM
Hello,
We are migrating from triggered tasks to Ultra tasks and encountering some difficulties with return payload formats.
I have a pipeline which integrates a Salesforce contact to a student object in an external system (accessed via SOAP service) via a force.com Apex trigger. The external system returns the student ID, login id and a version code once the integration is complete. The SnapLogic pipeline returns payload in the following format:
{
"StudentXNumber": "X000211",
"StudentVersion": "1",
"StudentLoginId": "userA"
}
This payload is parsed by the Apex trigger and used to update the relevant custom fields in the SF contact object (StudentXNumber, StudentVersion and StudentLoginId).
The portion of the Apex trigger which parses the pipeline response from SnapLogic looks like this:
/**
* Class representing response obtained from callout to integrate a Contact to a student
*
*/
public class DestinyOneContactIntegrationResult {
public String StudentXNumber;
public String StudentVersion;
public String StudentLoginId;
}
…
/**
* Given a DestinyOneContactIntegrationResult json-serialized payload, deserializes and
* populates data back into the given contact
*/
private static void populateContactIntegrationResult(Contact contact, String payload) {
List<DestinyOneContactIntegrationResult> resList =
(List<DestinyOneContactIntegrationResult>)System.JSON.deserialize(payload, List<DestinyOneContactIntegrationResult>.class);
// assume one response at this time
DestinyOneContactIntegrationResult intResult = resList.get(0);
contact.one_Student_X_Number__c = intResult.StudentXNumber;
contact.one_Version__c = intResult.StudentVersion;
contact.one_Login_Id__c = intResult.StudentLoginId;
}
This logic works successfully, when the task is executed as a regular triggered task. To trigger the task as an Ultra task, I’ve created a parent pipeline which runs the original pipeline (now a child pipeline) via a Pipeline Execute and returns the result of the call …
However, when the task is triggered as an Ultra task, the SnapLogic response format from the feedmaster is different somehow which causes the Apex trigger to fail on the deserialize call above…
My ultra pipeline looks like this. As you can see the return value of the subpipeline is being returned with no additional processing:
My force.com debug logs are as below:
38.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
08:03:42.0 (340149)|USER_INFO|[EXTERNAL]|00546000000HoO9|shenderson3@destinysolutions.com|Eastern Standard Time|GMT-04:00
08:03:42.0 (372137)|EXECUTION_STARTED
08:03:42.0 (376389)|CODE_UNIT_STARTED|[EXTERNAL]|FutureHandler - state load
08:03:42.0 (1917744)|CODE_UNIT_FINISHED|FutureHandler - state load
08:03:42.0 (2715296)|EXECUTION_FINISHED
08:03:42.14 (14404797)|USER_INFO|[EXTERNAL]|00546000000HoO9|shenderson3@destinysolutions.com|Eastern Standard Time|GMT-04:00
08:03:42.14 (14420197)|EXECUTION_STARTED
08:03:42.14 (14422800)|CODE_UNIT_STARTED|[EXTERNAL]|01p46000006EBak|DestinyOnePushToSnapLogic.runCallOut
08:03:42.14 (17724623)|SOQL_EXECUTE_BEGIN|[41]|Aggregations:0|SELECT g.Id, g.Name FROM CollaborationGroup g WHERE g.Name = :tmpVar1 LIMIT 1
08:03:42.14 (25529567)|SOQL_EXECUTE_END|[41]|Rows:1
08:03:42.14 (27303512)|SOQL_EXECUTE_BEGIN|[77]|Aggregations:0|SELECT Id, one_Student_X_Number__c, one_Version__c, one_Integration_Last_Status__c, one_Integration_Last_Success__c, one_Integration_Last_Attempt__c FROM Contact
08:03:42.14 (30317809)|SOQL_EXECUTE_END|[77]|Rows:1
08:03:42.14 (31115809)|CALLOUT_REQUEST|[99]|System.HttpRequest[Endpoint=http://destinypaymenttest.destinysolutions.com/berkeleyqa2/api/1/rest/feed-master/queue/DestinySolutions/development/Omair/SalesforceContactToDestinyOneTask, Method=POST]
08:04:59.733 (77733235108)|CALLOUT_RESPONSE|[99]|System.HttpResponse[Status=OK, StatusCode=200]
08:04:59.733 (77735367659)|FATAL_ERROR|System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set
Class.System.JSON.deserialize: line 15, column 1
Class.DestinyOnePushToSnapLogic.populateContactIntegrationResult: line 135, column 1
Class.DestinyOnePushToSnapLogic.runCallOut: line 104, column 1
08:04:59.733 (77735384067)|FATAL_ERROR|System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set
Class.System.JSON.deserialize: line 15, column 1
Class.DestinyOnePushToSnapLogic.populateContactIntegrationResult: line 135, column 1
Class.DestinyOnePushToSnapLogic.runCallOut: line 104, column 1
08:04:59.735 (77735392134)|CUMULATIVE_LIMIT_USAGE
08:04:59.735 (77735392134)|LIMIT_USAGE_FOR_NS|(default)|
A portion of my subpipeline (including the final mapper snap) is shown below.
What change must I make to my pipelines so that they run correctly in Ultra? Ideally I’d like to keep my Apex trigger unchanged (so that regardless of how I execute the task in SnapLogic the return payload format is the same)
Thanks,
Omair
07-05-2017 08:12 AM
Thank you @omair. I’ll take a look at it.
02-19-2020 09:15 AM
Hello,
I too face same issue. Trigger task payload is working fine with array enclosed brackets, whereas Ultra task is not accepting same payload. Data is taken as Null for the payload instead. Is there any update on this topic?
Thanks,
Mithila