Forum Discussion

DeviK's avatar
DeviK
New Contributor
4 years ago
Solved

Parent record value into child records

I’m pretty new to snaplogic and would like some help with a requirement. I have JSON records where the parent is coming a separate record followed by child records as below:

I would like to bring the parent field value(locationId) into the child records. Is there an easy way to accomplish this?

Thanks

3 Replies

    • DeviK's avatar
      DeviK
      New Contributor

      Thank you ! it works perfectly

  • Great solution @viktor_n! I had the same thought but you beat me to it. Here is an alternative solution which uses a few more snaps but uses less total memory if processing larger files since we won’t be pushing all of the data into a single document.

    Parent record value into child records_2021_12_04.slp (15.3 KB)

    Summary of steps:

    • Add a recordId to each document for later merging of records
    • Route the data so we can work with parents and children separately
    • Parent stream (top)
      ** Group all parent records into a single document as an array of values
      ** Add the “next” recordId for each parent
    • Join the “parent” records array to all child records
    • Filter out the parent associated with each child based on the recordId range and remove the extraneous fields