Forum Discussion

akarsh's avatar
akarsh
New Contributor III
2 years ago
Solved

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

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.

  • 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.

4 Replies

  • 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.

    • akarsh's avatar
      akarsh
      New Contributor III

      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 []? 

      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's avatar
        akarsh
        New Contributor III

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