Go back to flow logic
Summarize
Summary of Go back to flow logic
The Go back to flow logic feature in ServiceNow allows you to return to a prior step within a flow to repeat a sequence of actions. This is useful for looping or retrying sections of a flow based on specific conditions. It is available for flows created from the Washington DC release family onward.
Show less
Key Features
- Release Requirements: Only supported in flows created from the Washington DC family release forward; flows from earlier versions don’t support this logic.
- Placement Restrictions: Go back to flow logic must be placed within a branch of a parent flow logic block such as the ‘Then’ branch of If/Else If/Else, the ‘Answer’ branch of Make a decision, or the ‘Catch’ branch of Try flow logic. It cannot be placed inside an Error handler section.
- Valid Target Steps: The target step to return to must be:
- A step before the Go back to flow logic.
- Within the same parent flow logic branch (not in a different branch or the same branch).
- Outside non-branching flow logic blocks unless those blocks also contain a child Go back to flow logic.
- Not inside 'Do the following in parallel' flow logic.
- Loop Iterations Limit: All loops are subject to a maximum number of iterations set by the property
snflowdesigner.maxiterations. - Inputs: You specify the step to go back to, which must meet the above conditions.
- Outputs: This logic does not produce outputs.
Best Practices and Guidelines
- Add Go back to flow logic only after the flow’s structure is fully defined with valid target steps to ensure proper functioning.
- Avoid duplicate Go back to flow logic steps in a flow; only the first one whose conditions are met will execute.
- Prevent infinite loops by defining clear conditions to resume or terminate the flow, such as counters or error triggers.
- If relocating Go back to flow logic, you must delete it from its current location and re-add it to a valid new location since it cannot be moved directly.
Practical Implications for ServiceNow Customers
This feature enables efficient handling of repeated actions within flows, supporting scenarios like retrying approvals or looping over tasks. By following placement and target step rules, you can safely control flow iterations without causing infinite loops or logic errors. The iteration limit property safeguards against runaway loops, ensuring system stability.
Understanding these constraints and best practices helps you design robust, maintainable flows that leverage looping logic effectively.
Return to a prior step in the flow to repeat a sequence of actions.
Family release requirements
You can only add Go back to flow logic to new flows created from the Washington DC family release and forward. Flows that were created in versions prior to the Washington DC family release do not support Go back to flow logic.
Valid Go back to placement
- The Go back to flow logic must be within a branch of a parent flow logic block.
- Then branch of If, Else If, or Else flow logic
- Answer branch of Make a decision flow logic
- Catch branch of Try flow logic
- The Go back to flow logic must be outside of the Error handler section.
Valid Go back to target step
- The target must be a step before the Go back to flow logic.
- The target can't be a step within a different branch of the flow.
- The target can't be a step within the same branch as the Go back to flow logic.
- The target can't be a step within a non-branching flow logic block unless the non-branching flow logic block also includes a child Go back to flow logic.
- The target can be a step outside of a non-branching flow logic block except for Do the following in parallel flow logic.Warning:Selecting a target step outside of a parent flow logic block exits the current loop and resets its loop iteration count. The system displays separate loop iteration counters for the Go back to loop and the parent flow logic block. All loops are limited by the maximum number of loop iterations property (sn_flow_designer.max_iterations).
Inputs
| Input | Description |
|---|---|
| Go back to step | Step in the flow that meets the conditions of a Go back to step target. |
Go back to start of flow
In this example, the flow goes back to the first step when the approval task for the trigger record is rejected. Valid Go back to targets include steps 1, 2, and 3. Step 4 violates rule 2 as it's a step within a different branch. Steps 5 and 6 violate rule 3 in that they're steps within the same branch of the flow.
Outputs
This flow logic has no outputs.
General guidelines
Use these general guidelines when adding Go back to flow logic.
- Add Go back to flow logic after the flow structure is complete
- Go back to flow logic depends on a fixed sequence of steps to function properly. Wait to add Go back to flow logic until the flow has valid target steps.
- Avoid creating duplicate Go back to steps
- A flow uses the first Go back to flow logic whose conditions are met. The flow ignores all Go back to flow logic steps after the first.
- Avoid creating infinite loops
- Specify a condition to resume the flow or to throw an error with each Go back to loop. Error and resume conditions prevent a flow from running until it reaches the maximum number of loop iterations (sn_flow_designer.max_iterations property). You can use an If flow logic to check for loop end conditions. For example, create a flow variable that counts how many times the flow has run the Go back to flow logic. When the flow variable reaches a limit, end the flow.
- Delete Go back to flow logic to move it
- After you add Go back to flow logic, you can't move it to another location. You can only delete it from its current location and then add it to another valid location.