12-01-2021 03:45 AM
Hi, I have the below input data
AccountName,AccountID,PAccountID
Abc,5467,6000
dsd,6000,7000
dfghyh,7000,5467
In the output I want the Parent account name based on the input so the output will be like
AccountName,AccountID,PAccountID, PAccountName
Abc,5467,6000,dsd
dsd,6000,7000,dfghyh
dfghyh,7000,5467,Abc
Please help me how can I achieve that?
12-01-2021 04:03 AM
In the above json content, child appears to be before parent. So we can use Script snap to solve this. We have to cache all the documents. Once all the input docs are received then we can write to the output view as desired.
12-01-2021 04:12 AM
Hey @the_pan_zone,
Here’s a pipeline that does exactly what you need:
Inherit Parent AccountName_2021_12_01.slp (5.7 KB)
If by any means, there is a mistake in your CSV sample, because as @smudassir said, the child appears before the parent, and you need it other way around, than you need to change the Mapper expression to :
$input0.map((x,index)=> index == 0 ? x.extend({"PAccountName":$input0[$input0.length -1].AccountName}) : x.extend({"PAccountName":$input0[index-1].AccountName}))
Regards,
12-01-2021 06:28 AM
Thanks @bojanvelevski
it is working…Do you think it will work for .1 million records?
12-01-2021 06:38 AM
Hi @bojanvelevski ,
If I add one more row and change the source data
AccountName,AccountID,PAccountID
Abc,5467,6000
dsd,6000,7000
dfghyh,7000,5467
new,5000,5467
This time the code is not working