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

How to get around the limitation of not being able to assign nested source list

michelle-popovi
Deputy Chef II
Deputy Chef II

Hi,

I'm struggling with how to work around the limitation of not being able to add a source list within a source list.  I was able to setup the structure in a for-each loop the way that I want it (at that level the list is only 1 level deep as I iterated through the top list).  However, once outside the loop I want to add the whole structure to a list that later will be sent as an array of json items to an api call.  The issue is the limitation that I can't transfer the structure that I just setup to a list of the same structure...the datapills will not allow anything into this lower source list  In the example below the "Source mapping source list" is the list at the top level and "Values" is within that.  This is based on a structure that is read in from a get api call and massaged with additional data before POSTing it back.

Any suggestions that I can try...I'm stuck at this point.  TIA!

 

michellepopovi_0-1683205496611.png

 

1 ACCEPTED SOLUTION

gary1
Executive Chef III
Executive Chef III

Here's a way you can trick Workato to do this, but there are some downsides.

Let's say we have this payload, and you want to recreate this in a list:

 

[
  {"name": "vegetables",
   "list": [{"type": "garlic"},
              {"type": "onion"}]},
  
  {"name": "fruit",
   "list": [{"type": "apple"},
              {"type": "orange"},
              {"type": "pear"}]}
]

 

First, don't define the entire schema of the nested list. Instead, create a string input field.

gary1_0-1683663340921.png

Next, set the input field of the nested list to formula and drop in the "list" data pill.

gary1_1-1683663455916.png

Because it's in formula mode, Workato interprets the input as an array and parses it. (For fun, try re-running this with the input set to "text" and you'll see how Workato preserves the input as a string).

Here's the parsed output:

gary1_2-1683663498924.png

The downside of this method is without the fully-declared schema in the list action you can't easily access the data in the array with a data pill. However, you can still access the data using a formula with bracket notation. Here are some examples.

This navigates to the second item in the outside array and then the third item in the nested array and returns the full object:

Logger:

gary1_6-1683663712563.png

Output:

gary1_3-1683663636122.png

This navigates to the second item in the outside array and then the third item in the nested array and returns only the "type" value:

Logger:

gary1_7-1683663813957.png

Output:

 

gary1_5-1683663696700.png

Hope this helps!

View solution in original post

5 REPLIES 5

gary1
Executive Chef III
Executive Chef III

Here's a way you can trick Workato to do this, but there are some downsides.

Let's say we have this payload, and you want to recreate this in a list:

 

[
  {"name": "vegetables",
   "list": [{"type": "garlic"},
              {"type": "onion"}]},
  
  {"name": "fruit",
   "list": [{"type": "apple"},
              {"type": "orange"},
              {"type": "pear"}]}
]

 

First, don't define the entire schema of the nested list. Instead, create a string input field.

gary1_0-1683663340921.png

Next, set the input field of the nested list to formula and drop in the "list" data pill.

gary1_1-1683663455916.png

Because it's in formula mode, Workato interprets the input as an array and parses it. (For fun, try re-running this with the input set to "text" and you'll see how Workato preserves the input as a string).

Here's the parsed output:

gary1_2-1683663498924.png

The downside of this method is without the fully-declared schema in the list action you can't easily access the data in the array with a data pill. However, you can still access the data using a formula with bracket notation. Here are some examples.

This navigates to the second item in the outside array and then the third item in the nested array and returns the full object:

Logger:

gary1_6-1683663712563.png

Output:

gary1_3-1683663636122.png

This navigates to the second item in the outside array and then the third item in the nested array and returns only the "type" value:

Logger:

gary1_7-1683663813957.png

Output:

 

gary1_5-1683663696700.png

Hope this helps!

This is such a great walk-through, thank you for sharing @gary1 !

michelle-popovi
Deputy Chef II
Deputy Chef II

Thanks!...actually I was able to get it to work as I wanted...must be a quirk of the UI...the following instructions did it for me.

Just click on the list in the data pill 3 times, and then drag it to the destination box.

Hey Michelle,

I'm so glad it is working now! This data pill is giving some Dorothy vibes...

meghanlegaspi_0-1683668629442.gif

If you haven't already, please submit this product feedback via the Workato platform. From there, our team can look into this further.

Thank you,
Meghan