Forum Discussion
Hey @viji28,
How long was the execution? Was it over 15 minutes?
- bojanvelevski4 years agoValued Contributor
Hey @Walkback,
Use the .map() method on $orderLine. The expression should look something like this:
$orderLine.map(x=>x.extend({"countryIso" : "GB","sessionId" : "ed7e8228-a82b-44e0-adea-caee6c61a987"}))
Here’s also a sample pipeline:
Extend objects in array_2021_10_28.slp (3.9 KB)
Regards,
Bojan Bojan
Thank you for your feedback, but I have already tried that. I’m currently using a mapper snap (which maybe the wrong way to do it) used the data once, but there are after errors, because the 2 values are both null.
Is there a means of retaining the 2 values?
Jay
- bojanvelevski4 years agoValued Contributor
What should happen if the values are null? You can either filter those with a filter function:
$orderLine.filter(y=>y!=null)
or keep them as nulls with extending the expression with a ternary operator:
$orderLine.map(x=>x != null ? x.extend({"countryIso" : "GB","sessionId" : "ed7e8228-a82b-44e0-adea-caee6c61a987"}) : x)
It’s not clear how your countryIso and sessionId fields enter the pipeline (are they constants, pipeline parameters?), but I’ve attached an example that’s pretty simple and doesn’t involve javascript expressions. Uses a Splitter to break out the lines, then a mapper to add the countryIso and sessionId (orderId?), then a GroupBy to put it all back together. You can use a JSON formatter to spit it back out depending on what your are doing with it. Hope this gives you some ideas anyway.
walkbackCopyData_2021_10_28.slp (7.7 KB)