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

Hi @DeviK,

I’ve come to solution for your problem. Here is pipeline with the solution.
Community_Answer_2021_12_03.slp (9.1 KB)

Try it, see if it help you.

Regards,

3 Likes

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
1 Like