Forum Discussion
@manohar You’re welcome, happy to help! I made a mistake with my initial pipeline with the expression sl.ensureArray(jsonPath($, "$LINES[*].E1EDPT1.E1EDPT2"))
, which ended up replicating the “TDLINE” items to every “POSEX” and ultimate leading to the merged string you observed.
I updated my pipeline to use a JSON Splitter to break “LINES” up first before performing sl.ensureArray($E1EDPT1.E1EDPT2)
- effectively doing the same thing we did before but with no replication of “TDLINE.” Here is a screenshot of the pipeline:
Here is the final output of the “Construct Orderlines” Mapper Snap:
Also, since we’re using sl.ensureArray($E1EDPT1.E1EDPT2)
to make sure “E1EDPT2” is an array, I also cleaned up your Mapper expression to remove the ternary expression that used typeof
to determine if it was an array or object. The updated expression looks like this:
$LINES.map(x => {"line-num": x.POSEX,"attachments":{'type':"AttachmentText",'intent':"Supplier",'text': Date.parse(Date.now()).toLocaleDateTimeString({"timeZone":"US/Eastern", "format":"yyyy-MM-dd HH:mm"}) + " :- " + x.E1EDPT1.E1EDPT2.map(y=>y.TDLINE).toString().replace(/\,/g,"").replaceAll("<br/>","\n").replaceAll('], [','\n').replaceAll('[','').replaceAll(']', '')}})
Please let us know if this fully addresses your question or if not, where does this fall short.
Here is the pipeline:
Community_ArrayVsNonArray_2021_07_29.slp (12.4 KB)
An Alternative way of doing it would be on Mapper you can split $LINES[*].E1EDPT1 and in the mapper
sl.ensureArray($E1EDPT2)
for_Array_Text_2021_07_30 (1).slp (6.0 KB)
Related Content
- 2 years ago
- 6 years ago
- 7 years ago
- 3 years ago