โ05-04-2023 06:21 AM - edited โ05-04-2023 06:29 AM
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!
Solved! Go to Solution.
โ05-09-2023 01:28 PM
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.
Next, set the input field of the nested list to formula and drop in the "list" data pill.
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:
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:
Output:
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:
Output:
Hope this helps!
โ05-09-2023 01:28 PM
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.
Next, set the input field of the nested list to formula and drop in the "list" data pill.
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:
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:
Output:
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:
Output:
Hope this helps!
โ05-09-2023 02:41 PM
This is such a great walk-through, thank you for sharing @gary1 !
โ05-09-2023 01:31 PM
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.
โ05-09-2023 02:44 PM
Hey Michelle,
I'm so glad it is working now! This data pill is giving some Dorothy vibes...
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