Push to array output variable in subflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 12:45 PM
In Flow designer, I have an output variable that is an array of objects. Within my subflow, I am iterating through a list of records and performing some operations (assembling data, calling a REST API, etc.) There are a handful of results for each given record, so I want to capture all of those results within my array.
My problem is that, while there is a Flow Logic to "Assign Subflow Outputs", it seems to only allow me to set my output array and/or its individual elements. For each of my records, I want to be able to push to the array. Is that possible?
Basically, I want Flow to be doing something like this:
while (gr.next()) {
var result = doThings();
output.my_array.push(result);
}
But it only appears to let me do this:
while (gr.next()) {
var result = doSomething();
output.my_array = result
// or
output.my_array[0] = result;
}
It seems to me, only allowing setting of the array or hardcoded indexes completely defeats the purpose of an array.
- Labels:
-
Scoped App Development
- 3,471 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2022 02:56 AM
Hi Bradley,
Instead of pushing each result into an output, try pushing all results into an array first and then setting the array to output.
Example.
while (gr.next()) {
var myArray = [];
for (var i=0; i<.....; i++) {
var result = doThings();
myArray.push(result);
}
output.my_array = myArray;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2022 03:01 PM - edited ‎12-15-2022 03:16 PM
Hi Bradley,
There appears to be an action in Flow designer called JSON Processing that will take any raw json string and convert it to an Array.Object which can then be used in later For loops etc which should solve your problem. Here is a couple images to help. I have not used this yet, but have have used a similar in action step called JSON Parser that will do the same and allow an action to include an Array.Object as an output. Ultimately if that Action does not do what you want you can create an action which has one step (JSON Parser) and then output the Array.Object from there to be used as desired.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2022 12:02 AM
I believe that option is only available if you have Integration Hub Professional or Enterprise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2022 08:58 AM
If you do not have Integration Hub you can still do this same thing by creating a custom action > adding a script step and in the scripting step taking the rawJSON input putting it in JSON.parse(<rawJSON>); and setting that result to a custom output that fits the JSON structure. That JSON output pill can be an Array.Object which is then available for later actions to consume.