cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Get value from list with multiple nested objects, based on a where formula

mlamotte
Deputy Chef III
Deputy Chef III

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

1 ACCEPTED SOLUTION

shivakumara
Executive Chef I
Executive Chef I

Community_JSON.jpgHi @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

View solution in original post

2 REPLIES 2

shivakumara
Executive Chef I
Executive Chef I

Community_JSON.jpgHi @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

Thanks, even better solution!