Need Help Understanding How to Use Subflows in ServiceNow

AbhishekChaudh
Tera Contributor

Hi everyone,

I’m new to using Flow Designer in ServiceNow, and I’m finding it a bit confusing to understand how subflows work. I’ve read the docs but still feel stuck.

If anyone can help me with a simple example or step-by-step explanation, that would be awesome

7 REPLIES 7

Brian Bouchard
Mega Sage

hi @AbhishekChaudh - Think of subflows like multi-step actions.  They are used to contain repeatable code and/or to break down complex flows into smaller, more manageable parts. If you're familiar with how script includes can contain reusable code for scripts, it's the same concept, but for flows.

a fairly simple use case would be something like an employee onboarding where part of that flow is adding someone to an Active Directory group.  You could use a single action to add them to the group and then check to see if it fails and try to react, or you could be a bit more proactive and have the following steps in your flow:

1. check to see if the group exists
2. If the group exists, check to see if the user is already a member of the group.

3. If they are NOT a member, add them to the group
4. If they ARE already a member, add a work note to the task stating nothing was done because the user was already a member of the group.

You can do all of these steps in your onboarding flow, but if you have other flows for adding people to specific groups, like when ordering software, you will need to recreate all those steps again for that flow.

But if you put that logic into a subflow, you just need 1 line to call the subflow, passing in the user and group that you want to add them to.  And anytime you have a flow that is trying to add someone to an AD group, you can simply call that subflow from your flow and know exactly how it works, saving time, effort, and improving the readability of your main flow.  Another benefit of using the subflow is if you need to make a change to that logic, you only need to make the change in one place and know that it will be picked up by all the places that access that subflow vs. going into every individual flow to make the same update over and over again.

Thanks @Brian Bouchard . I'm new to Sysadmin in ServiceNow and this has help me understand subflows a little better. 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @AbhishekChaudh 

 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/xanadu/servicenow_application_develop...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

AndersBGS
Tera Patron
Tera Patron

Hi @AbhishekChaudh ,

 

 subflows are in general flows that can be reused by multiple flows, and called directly from a flow it self. So think art is as a part of the flow but now visual in the main flow

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/