Can I recursively call a flow or subflow?

jordimsant
Tera Guru

I was trying to develop a flow and this question came to my mind. Is it possible to create loops using a flow? Can I recursively call a flow to achieve this goal? I have tried many ways and I have not found how to do it.

6 REPLIES 6

Hitoshi Ozawa
Giga Sage
Giga Sage

Not certain why you would want to recurve flow.

It is possible to create a recursive flow as is written in the following page but there is usually a better way to define a flow without recursion.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0830765

You maybe given a record and need to find all associated sub records / flows to it and any children.

Cannot do in a single call as there is now way of getting the values until you know the next level

Your RITM calls a flow, so the first record is the RITM sys_id
You now search on the sys_id of the sys_flow_context to get all sub flows from the first flow.
Repeat until you have no further flow contexts

 

Likewise for RITM/Task or anykind.  Seen many where the flow will do some work and a customer has allowed their itil users to add another type of record, and the parent value is not the calling REQ/RITM, but maybe a sc_task, vtb_task and so on.

Kiran_45
Giga Guru

Hello @jordimsant,

If you are talking about looping, you can always use Do the following flow logic to create a loop that repeatedly applies one or more actions. This flow logic requires a condition specifying when to stop the loop.


You can go through product documentation! 

https://docs.servicenow.com/bundle/xanadu-build-workflows/page/administer/flow-designer/concept/flow... 

 

Please hit the thumbs up if this info helps!
Thanks!

 

 

 

Maybe, but too many loop steps or overall steps will stop a flow

By calling a subflow recursively you eliminate that

 

For the example above, on the sys_flow_context, no idea how many flows or subflows are called, so where does you loop end and how many steps.

You can call a sub flow and run 100 steps with no worries, can't do that as an all in one flow