cancel
Showing results for 
Search instead for 
Did you mean: 

How to get value based on a incoming document

the_pan_zone
New Contributor

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?

10 REPLIES 10

It’s hard to tell, theoretically it will work, but you’re sending 1 million records in one array, so I would say it depends on the records?

The solution is not hardcoded, it’s designed to dynamically add the new field:

image

Re-check the setup of the pipeline.

the_pan_zone
New Contributor

Hi @bojanvelevski ,

Please check the 3rd row in your result set.
Here PAccountName should be ABC instead of “new”. PAccountName should not be the next one it should depend on PAccountID. As PAccountId is same for both 3rd and 4th row so PAccountName should be also same i.e. Abc for both 3rd and 4th Row.

Ah, this clarifies things. It was a misunderstanding, the expression you need to use is the following:

$input0.map((x,index)=> x.extend({"PAccountName":$input0.filter(y=>y.AccountID == x.PAccountID)[0].AccountName}))

the_pan_zone
New Contributor

Hi @bojanvelevski ,
its working fine now.
Thank you

the_pan_zone
New Contributor

Hi @bojanvelevski ,

if I change the source and put a null in one row
AccountName,AccountID,PAccountID
Abc,5467,6000
dsd,7000,6000
dfghyh,6000,‘’
new,5000,5467

I am getting the following error in the expression
Failure: Cannot access element 0 of ‘$input0.filter(y=>y.AccountID == x.PAccountID)’, which is empty, Reason: Index was out-of-bounds, Resolution: Please check expression syntax and data types.

Expected output should be if there is not parent ID then there will be no parent name corresponding that row.
Can you please let me know if we can use any null handling here