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-01-2017 03:24 PM
Remember the compatibility of certain snaps for Ultra pipelines. Aggregate
and certain snaps will not work with Ultra configurations. Do you have any
of them?
You cannot just straight away convert from Triggered to Ultra. It just wont
work as is. You will have to consider retesting and converting certain
snaps.
Thanks & Regards,
Naveen
07-01-2017 06:05 PM
@nganapathiraju thanks for your message. Maybe my question was a bit unclear. My pipeline runs successfully both as a triggered task and as an Ultra task. The problem is that it appears that the return payload for Ultra is different from a regular triggered task. I have not been able to find documentation that clearly specifies if or how the return payload for a pipeline (functioning correctly under ultra) is different as a triggered task vs an ultra task. The behavior of my pipeline strongly suggests that that is the case. I was hoping for some assistance in identifying how the return value of an ultra pipeline is different.
Omair
07-02-2017 05:12 PM
Review this
Maybe that will help. Definitely the return from Ultra is different from
Triggered in the sense that content is also json encoded depending on how
you handle in your mapper.
Thanks & Regards,
Naveen
07-05-2017 05:16 AM
For the benefit of anyone who’s been following this thread, I ran a simple test using a pipeline with a single Mapper snap:
Running the pipeline as a triggered Task returns:
[
{
"StudentXNumber": "X002221",
"StudentVersion": "7",
"StudentLoginId": "X002221"
}
]
Running the pipeline as an Ultra task returns:
{
"StudentXNumber": "X002221",
"StudentVersion": "12",
"StudentLoginId": "X002221",
"original": {
... original payload
}
}
The two key differences are:
@dmiller this distinction should probably be noted on the documentation page for Ultra tasks because it means that client code that is calling a triggered task will not work if the task is reconfigured as an Ultra task.