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,245 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2022 01:01 PM
Hi,
Look at this video by

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2022 06:28 AM
That video deals with complex objects inside an action where the action's output is being set by script. That's not what I'm looking for.
I've created a simplified version of what I'm doing in my subflow here:
For each of my records, there are a couple different things that can happen. I want to know the result for each of those records. I want the output of the subflow to look something like this:
[
{
record: "INC123456",
message: "Something happened"
},
{
record: "INC123457",
message: "Something else happened"
}
]
But the way that Assign Subflow Outputs appears to work, I'll only get this output from the subflow:
[
{
number: "INC999999",
message: "This is the last record that was iterated on"
}
]
...because it's just resetting index 0 for each iteration. I want to be able to push to the output array for each iteration.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2022 12:34 AM
Sorry for the spamming of my first reply.
When I posted, the replies disappeared.. but somehow got saved anyway.
Sadly I don't know if there is a way to push values to an output array the way you described.
The Assign subflow output action, does exactly that, it sets a value.
A workaround would be to build your output into a custom action, which returns an array.object, which you could use to assign the output from your subflow.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2022 07:04 PM
Hi,
Understood the situation by viewing the flow screenshots.
AFAIK, it's not possible. Subflow is used to return a reply so there's a need to move the loop to the main flow.
Setting output in a subflow within a loop will overwrite the previous output. That's the current specification.