01-22-2024 03:41 AM
Input Structure
[
{
"Id": "ABC",
"IFA_Number__c": "1"
},
{
"Id": "BCD",
"IFA_Number__c": "2"
}
]
I have to save this data in a key value format ( Ifanumber is key and ID is value) so that later in mapper I have to fetc fetch the respective ID based on IFA number. what's best way to do this?
Solved! Go to Solution.
01-23-2024 12:35 AM
Hello @akarsh,
You can try with grouping all of the documents into a single array, then using reduce to combine them in one object.
Please note that if you have duplicate keys through the documents, they will overwrite.
Please refer to the attached pipeline and let me know if this helps you.
Regards,
Aleksandar.
01-30-2024 12:51 AM
You can try with the following expression:
$dataList.map(x => x.get('IfaNumber',null)).filter((x,ind,arr) => x != null && arr.indexOf(x) == ind)
Let me know if this helps.
Regards,
Aleksandar.
01-23-2024 02:33 AM
Thanks a lot, it worked.
01-29-2024 11:50 PM
@Aleksandar_A there is a possibility that IcustomerIFANumber might not be present . is there a way to skip the mapping when its not present?
$dataList.map(x => x.customerIFANumber != null ? x.customerIFANumber : null).filter((x,ind,arr) => arr.indexOf(x) == ind).toString()
01-30-2024 12:39 AM
Hello @akarsh,
Could you please share an example of your input and the expected output?
01-30-2024 12:45 AM
Sorry I posted the question in wrong thread.
input will be like this
{
"totalCount": 4,
"dataList": [
{
"IfaNumber": "1",
"alink": "",
"agroupId": ""
},
{
"IfaNumber": "2",
"alink": "",
"agroupId": ""
},
{
"IfaNumber": "3",
"alink": "",
"agroupId": ""
},
{
"alink": "",
"agroupId": ""
}
]
}
Output
["1","2",3"]
this question
01-30-2024 12:51 AM
You can try with the following expression:
$dataList.map(x => x.get('IfaNumber',null)).filter((x,ind,arr) => x != null && arr.indexOf(x) == ind)
Let me know if this helps.
Regards,
Aleksandar.