cancel
Showing results for 
Search instead for 
Did you mean: 

Parent record value into child records

DeviK
New Contributor

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:

image

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

Thanks

1 ACCEPTED SOLUTION

viktor_n
Contributor II

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,

View solution in original post

3 REPLIES 3

viktor_n
Contributor II

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,

DeviK
New Contributor

Thank you ! it works perfectly

koryknick
Employee
Employee

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