Converting an items to subflow

The ServiceNow feature of converting an items to subflow can be widely used in the area where the same repeated set of consecutive actions are required in the multiple flows or subflows. We can just select the consecutive actions by clicking on the ‘Select Multiple’ link in the flow or subflow after that we can click on ‘Convert to subflow’ operation which will convert it into a new subflow in the same scope of the main flow.

Let us consider one example where we have one custom application where end users used to create an account request through record producer in the portal which have one level approval. Once that request is approved, the account record becomes active. The account approval is dependent on some criteria which decides whether the approval will go to user A, user B or User C. These three are the user fields in the account form and only User C is mandatory field.

The requirement is, first it should check if user A is active, the approval should go to the User A. If user A is inactive, then it should check for User B and if user B is active, the approval should go to user B. In the last if user B is also inactive, the approval should trigger to user C. Now assume, we have initially, created the flow for the same without using any subflow. Then in the later the client gave another requirement that if there is any pending approval for account to user A and if that user becomes inactive before approving or rejecting that request, then that flow should retrigger again and it should check if user B is active, the approval should go to him and so on.

So, in that scenario, what we can do is, we can convert the entire flow into subflow using the below procedure and  we can create one more flow for which the trigger condition was when any user becomes inactive and we will check if that user has any pending account approval with him. If yes then we will call the converted subflow there in the new flow.

So that new subflow can be used in the both places. One in the account request flow and one in the user inactive flow. And in this way we can achieve the requirement too easily and quickly, otherwise we would have deleted the entire flow actions and created a new subflow and would have added in the two flows.

By this new feature, it becomes very easy and quickest for resolving the above issue.

Now, I will explain how we can convert the consecutive items of a flow into a new subflow that preserves data pill references between the converted items.

User having below roles can achieve this:

(i)flow_designer

(ii)admin

When we convert consecutive actions into a subflow, the data pill references are preserved and it transforms function from the original flow. Flow designer creates the new subflow in the same application scope as the original flow. Steps required: Step1: Navigate to All > Process Automation > Flow Designer. Step2: Open the flow you want to edit. Step3: From the action outline, click on Select multiple link. Once you click on the link, a checkbox is displayed next to each action.

Step4: Select one or more consecutive actions which you want to convert into a flow.

Step5: From the operations menu, select the Convert to subflow icon. Flow designer shows Convert to subflow dialog box.

Step6: In the dialog box, enter the name of the subflow of your choice and click on Convert to subflow button in the bottom.

Step7: The new subflow will be created and it be will added in the flow. You need to save and publish again the updated flow to keep the changes.

Conclusion:

Converting consecutive actions to a subflow helps in reducing the double or triple efforts or writing the same set of actions again and again. If there is a need or requirement of using the same set of actions in multiple flows or subflow better create a subflow for it and use it wherever it is required. If you missed it and later you found that it will be used again in some other flows or subflows, select those actions together and convert them into subflow with the name of your choice. It will create the subflow in the same scope as the flow.

By – Afsar