Forum Discussion

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

Create Key: Pair value in mapper

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 t...
  • Aleksandar_A's avatar
    Aleksandar_A
    2 years ago

    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.

  • Aleksandar_A's avatar
    Aleksandar_A
    2 years ago

    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.