- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 12:46 AM
Is there an action in a subworkflow
to generate Return X tasks depending on the script?
I have to check at the beginning of the flow via script if 1 or more tasks have to be created.
Return would be an array or multiple objects.
For each of these return values I want to create a task.
But not in script but " properly" as a flow action.
Is this possible
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 01:19 AM
Hello @Meloper,
yes, in general that would be possible. Your action/script would have to provide an array as an output (e.g. an array of objects):
Then with a for each logic in Flow Designer you can loop over all those objects and create a task in each loop execution using already existing flow actions like "create record".
I am not sure about your script logic, but I would try to replace this with low code logic as well e.g. "lookup records" action can typically be used to create an array of multiple objects. Then you can avoid scripting at all and dont have to deal with creating the array output via script which can be quite difficult.
I hope this helped. If yes, I would appreciate if you could mark this answer as "correct solution". Thank you!
Greetings,
Sören

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 01:19 AM
Hello @Meloper,
yes, in general that would be possible. Your action/script would have to provide an array as an output (e.g. an array of objects):
Then with a for each logic in Flow Designer you can loop over all those objects and create a task in each loop execution using already existing flow actions like "create record".
I am not sure about your script logic, but I would try to replace this with low code logic as well e.g. "lookup records" action can typically be used to create an array of multiple objects. Then you can avoid scripting at all and dont have to deal with creating the array output via script which can be quite difficult.
I hope this helped. If yes, I would appreciate if you could mark this answer as "correct solution". Thank you!
Greetings,
Sören
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 01:58 AM
Thanks, I'll try that directly.
And would this also work if I have multiple arrays as output?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2023 05:26 AM
Hello @Meloper,
Yes, you can have multiple arrays as output of a Flow Designer Action and then you can either iterate independently over them or build a "nested loop" where you first iterate over the one array and then in a second loop inside the first loop over the second one. Depends on what you want to achieve.
I hope this helped. If yes, I would appreciate if you could mark this answer as "helpful". Thank you!
Greetings,
Sören
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2023 11:41 PM
Hi Soeren, can you maybe check this: Flow - Custom Action returns Array.object but For... - ServiceNow Community