โ09-11-2024 06:43 AM - edited โ09-12-2024 01:54 AM
Hi,
We have a Parse EDI task, of which the output we put in a list.
For a specific field, we need to pluck a value, based on a qualifier in an object.
The list "MOA loop" contains multiple "MOA" objects, each with an object "MonetaryAmount", which in itself contains 2 variables.
Based on the value of the first variable, we want to select the value of the 2nd variable.
Example below:
{ MOA loop:
[
{
MOA:
{
MONETARYAMOUNT 01:
{
Monetaryamounttypequalifier 01: 176,
Monetaryamount 02: 2588.16
}
}
},
{
MOA:
{
MONETARYAMOUNT 01:
{
Monetaryamounttypequalifier 01: 86,
Monetaryamount 02: 15528.98
}
}
},
{
MOA:
{
MONETARYAMOUNT 01:
{
Monetaryamounttypequalifier 01: 79,
Monetaryamount 02: 12940.82
}
}
},
{
MOA:
{
MONETARYAMOUNT 01:
{
Monetaryamounttypequalifier 01: 125,
Monetaryamount 02: 12940.82
}
}
}}
From this list, we want to get the Monetaryamount 02 where the Montaryamounttypequalifier 01 = "125".
Can someone help with this?
Thanks in advance!
Solved:
MOA.where('MOA.MONETARYAMOUNT_01.Monetaryamounttypequalifier_01':"86").pluck(['MOA','MONETARYAMOUNT_01','Monetaryamount_02']).first
Solved! Go to Solution.
โ09-16-2024 03:52 AM - edited โ09-16-2024 03:53 AM
Hi @mlamotte
MOA.pluck("MONETARYAMOUNT_01").where(Monetaryamounttypequalifier_01: "125")
i.e. MOA is a Object
Make it more dynamic by using .where condition after .pluck operation.
Thanks and Regards,
Shivakumara Avadhani
โ09-16-2024 03:52 AM - edited โ09-16-2024 03:53 AM
Hi @mlamotte
MOA.pluck("MONETARYAMOUNT_01").where(Monetaryamounttypequalifier_01: "125")
i.e. MOA is a Object
Make it more dynamic by using .where condition after .pluck operation.
Thanks and Regards,
Shivakumara Avadhani
โ09-16-2024 11:56 PM
Thanks, even better solution!