โ12-17-2020 05:43 AM
Hi,
Iโm looking for the most efficient way to copy values from a parent object to a multi-instance child object. For instance, if I need start and end dates from an order header on the order lines.
I should also add that Iโd like to rename some of the attributes. Iโve been able to do this with the structure snap, but instead of creating a string, it creates an array.
Thanks,
Will
โ12-21-2020 10:25 AM
Hi,
To copy a field from the root object into the child objects, try a combination of the map
and extend
functions of the expression language:
Hereโs another variant that just uses map
and an object literal which both copies the date
and renames the index
to lineNum
:
โ12-22-2020 05:10 AM
Yes, this works. I just wanted to see if there was a standard snap that would be more straight-forward and to make sure there arenโt any performance concerns with using map and extend.
โ12-22-2020 08:19 AM
Depending on your use case, it might be possible to use the JSON Splitter instead. It can split the child array into separate output documents, and copy any desired fields from the parent (using Include Paths
) or all of the parentโs fields (using Include scalar parents
). But I wouldnโt worry about a potential performance with Mapper unless you observe an actual performance issue with Mapper.
Hope that helps.
โ12-28-2020 01:07 PM
Sounds good, thanks for your help!