Reputation: 9737
Afternoon. I am pulling fields out of salesforce using snaplogic and then calling a rest api with the results. One of the fields that I am mapping to the POST JSON Body needs to be an array. One of the fields that I am pulling out of salesforce is string that is semi-colon delimited. Looking at the snaplogic documentation there is a split(';') function that I can call. In the mapping snap I get this error whenever I try and add an expression to the end of the Salesforce field:
cannot lookup a property on a null value
Is there an example somewhere of splitting a string in a mapper snap and applying it to a rest html body? The documentation on the snaplogic site will verbose is nevertheless unhelpful.
Upvotes: 1
Views: 2473
Reputation: 4131
You can use the split()
method to output an array from the mapper snap.
Following is a sample pipeline:
Input JSON in the JSON generator:
[
{
"msg" : "Test 1;Test 2;Test 3"
}
]
All settings are left to default.
Mapper Snap:
Expression: $msg.split(';')
Output: [{"msg_array":["Test 1","Test 2","Test 3"]}]
Upvotes: 1