Subflow Action - create task for every Script return value

Meloper
Kilo Sage

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

1 ACCEPTED SOLUTION

Soeren Maucher
Mega Sage

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): 

SoerenMaucher_0-1674810824666.png

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

 

View solution in original post

6 REPLIES 6

Soeren Maucher
Mega Sage

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): 

SoerenMaucher_0-1674810824666.png

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

 

Thanks, I'll try that directly.
And would this also work if I have multiple arrays as output?

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