cancel
Showing results for 
Search instead for 
Did you mean: 

Filter Single attribute from JSON list to use it in a like query

akarsh
New Contributor III

My Input looks like this. 

{
"totalCount": 4,
"dataList": [
{
"IfaNumber": "1",
"alink": "",
"agroupId": ""
},
{
"IfaNumber": "2",
"alink": "",
"agroupId": ""
},
{
"IfaNumber": "3",
"alink": "",
"agroupId": ""
},
{
"IfaNumber": "1",
"alink": "",
"agroupId": ""
}
]
}

 Can anyone help me to get all the unique IfaNumber from the json list in mapper and form the output in form of ["1","2",3"]

So that I can pass it in Salesforce Lookup snap to get all the account Id for respective IfaNumber.

1 ACCEPTED SOLUTION

AleksandarAngel
Contributor III

Hello @akarsh,

You can try with the following expression in a Mapper Snap:

$dataList.map(x => x.IfaNumber).filter((x,ind,arr) => arr.indexOf(x) == ind)

This expression, first maps only the IfaNumber values from the dataList array, then filters out the duplicates.

Attaching the sample pipeline below.

 

Let me know if this helps you!

Regards,

Aleksandar.

View solution in original post

4 REPLIES 4

AleksandarAngel
Contributor III

Hello @akarsh,

You can try with the following expression in a Mapper Snap:

$dataList.map(x => x.IfaNumber).filter((x,ind,arr) => arr.indexOf(x) == ind)

This expression, first maps only the IfaNumber values from the dataList array, then filters out the duplicates.

Attaching the sample pipeline below.

 

Let me know if this helps you!

Regards,

Aleksandar.

One more question on this, I want to send this data to a lookup snap , is it possible to send the data with () brackets instead of []? 

akarsh_0-1705893334989.png

You can see here that , its a IN query it's syntax should be like IN ('1','2','3') but if I pass the mapper data directly it goes as ([1,2,3])

akarsh
New Contributor III

Thanks, SOQL snap helped here there is a option to not add escape char there.

akarsh
New Contributor III

Thanks a lot. I will try it out.