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!