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

Get List of Values out of Nested list of Hashes

Gebharthm
Deputy Chef II
Deputy Chef II
{
  Entries: 
[
     
{
      Entry ID: 23148031822,
      Entry: 
{
        Username: Carol,
        User ID: 12345,
      }
    },
     
{
      Entry ID: 654354654654,
      Entry: 
{
        Username: Mary,
        User ID: 98765,
        
      }
    }
  ]
}

 

Hi there! I would like to grab a list of the user IDs to look like, [12345, 98765] as a variable. I have it set to a string right now, as I can't get the entries list to pop up as a data pill in the workato array variable. 

 

I have had no luck using format_map or pluck, so please let me know where I am going wrong. I am trying to avoid using a for-loop, but I will if I have to.

 

Thanks!

 

Hailey Gebhart

3 REPLIES 3

gary1
Star Chef I
Star Chef I

If you want to return an array, you need to do entries.pluck("entry").pluck("user id")

Note that "entry" and "user_id" are not the exact keys you need to pluck. You need to pluck them based on their "API Name", which you can see by hovering over the data pill in the recipe data panel. Check this other post where I explain it in more detail:

https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-reference-a-list-item-in-a-da...

Also, your variable probably shouldn't be set to an array. Workato doesn't play well with primitive arrays like this, so you should actually just make a string variable, set it to formula mode, and use the above code to create the array.

If you want to convert the primitive array into a "Workato list", this requires a few additional steps.

I go this to work. Thank you so much for the helpful advice!

Obugari
Deputy Chef III
Deputy Chef III

Hi,

To get values from nested list we can use formula mode and try in this way flatten.pluck('List_name').flatten.pluck('list_name) pattern . So we can get all nested values in this method 

Attached the working method in screenshot .please refer once 
Thankyou

 

This is structure i have defined for nested listsThis is structure i have defined for nested listsFormula implemented to get nested listFormula implemented to get nested listoutput for nested list 1output for nested list 1tried to pluck another nested listtried to pluck another nested listOutput for nested list 2Output for nested list 2