Workflow Studio flow logic blocks make a flow conditional, repetitive, or time-aware. Use If or Make a decision to choose a branch, For Each or Do the following until to repeat work, Try to keep a flow running after an error, and Wait for a duration to pause. Subflow and workflow blocks handle reuse.
The blocks grouped by the job they do
The library holds seventeen blocks, and sorting them by the question each one answers is quicker than reading them alphabetically.
| Job in the flow | Blocks | Question it answers |
|---|---|---|
| Choose a path | If, Make a decision | Which branch should this record take? |
| Repeat work | For Each, Do the following until | Should these steps run per item, or until a state changes? |
| Adjust a loop | Skip Iteration, Exit Loop, Go back to | Skip this pass, end the loop, or return to an earlier step? |
| Handle failure | Try, End Flow | Keep going after an error, or stop? |
| Pause | Wait for a duration | How long should the flow wait, and on which schedule? |
| Run in parallel or call out | Do the following in parallel, Call a workflow, Dynamic flows | Run beside other work, inside another workflow, or chosen at runtime? |
| Move values | Set Flow Variables, Append to Flow Variables, Assign subflow outputs, Get Flow Outputs | How does data travel between steps and back to a parent? |
If or Make a decision: choosing the branch logic
An If block suits one check or a short set of checks. It has a condition label, which gives the branch a readable name, and a condition set built from record data such as a task’s state or an incident’s urgency. The Then branch runs when the conditions evaluate to true, and a child If can be nested inside a Then branch. In an If block, mixing AND and OR conditions on one field can produce a condition set that never evaluates to true. Group the OR conditions for a field in one condition set and the AND conditions in another.
Make a decision suits situations with many paths. Its rules live in an external decision table, a sys_decision record. With Use Branches selected, each answer in that table becomes its own branch. With it cleared, the block returns the matching answer records instead. The table can take any number of inputs, stored as sys_decision_input records. A car insurance quote is one illustration, with age, accident history and car model as inputs. For evaluating the same kind of table from a script, see the DecisionTable API guide.
When several If blocks differ by one value and perform the same action, replace them with one Make a decision block. Three If blocks that each create an incident task for a different category can become one block whose answer feeds the Create task action.
The execution setting controls how many answers run: “First decision that matches” returns one answer, while “Run all decisions that match” returns all matches with a count. The Use Branches check box shows each answer as its own branch; clearing and confirming it removes those branches, and reselecting it does not restore them. Include Otherwise adds an Else-style branch, which does not run when the table has a default answer.
Repeating work with For Each and Do the following until
For Each applies its actions to each record in a list. The Items input takes sys IDs or a Records data pill, often produced by a Look Up Records action. Sort the list first if processing order matters. Keep lists under 1,000 records, and split larger work across several flows. Stages go before or after the loop, not inside it. Nested loops over many records can hit the flow transaction quota, which stops any flow running longer than an hour. Execution details keep the first and last iterations by default. For large loops, turning off reporting through the com.snc.process_flow.reporting.level system property reduces resource use.
Do the following until repeats its actions until an end condition is met. It takes a condition label and the conditions, and it produces no outputs. If the end condition is already true when the flow starts, the loop runs once and then stops. Flow variables can count passes for a custom end condition, such as a daily email about an incident until that incident is closed or canceled.
Adjusting a loop: Skip Iteration, Exit Loop and Go back to
- Skip Iteration (also called continue) ends the current pass and moves to the next item. It sits in the Then branch of an If, Else If or Else block, and the parent loop must define skip conditions.
- Exit Loop (also called break) leaves the loop and resumes the flow after it. It follows the same placement rule, and the remaining loop steps do not run.
- Go back to returns the flow to a prior step so a sequence repeats. It requires flows created from the Washington DC family release onward. It belongs in the Then branch of an If, Else If or Else block, the Answer branch of a Make a decision block, or the Catch branch of a Try block, and it must sit outside the Error handler section.
Add Go back to once the step order is final, because it depends on that order. Its target must come earlier in the flow and sit in neither a different branch nor the same branch. Guard each loop with a counter flow variable checked by an If block; otherwise the loop runs until the maximum loop iterations property, sn_flow_designer.max_iterations, stops it. A placed Go back to block cannot be moved, so delete it and re-add it.
Handling errors with Try and ending a flow with End Flow
The Try block has no field inputs; you add the actions to attempt under its plus icon. When one fails, that action reports Completed (error caught), and the Catch branch can test that status. A critical priority network incident might try an SMS message, then a Connect message, then an email, each after the last attempt fails.
End Flow stops the current flow, and nothing can follow it. Reaching it ends all branches, including branches waiting in a Wait for a duration block and parallel paths still running, and the state is set to Completed. An ended subflow returns no values unless an Assign subflow outputs block sits before its End Subflow block, so the parent flow should handle a subflow that returned nothing.
Waiting with Wait for a duration
The block offers three duration types. Explicit waits a fixed period. Relative counts from a Duration data pill or a date and time value, before or after it. Percentage waits a share of the time between the block’s start and a chosen end time, from 0 to 100. A single wait can reach 999 hours, and queued work can lengthen the real pause. A schedule option turns the wait into schedule time, so a 10-hour wait on a weekday schedule spans business days. For a pause that depends on a condition instead of a set time, see Wait for Condition.
Running work in parallel and calling other flows
Do the following in parallel runs actions and subflows in separate paths inside an isolated block, and the block completes when its paths finish. Paths can finish in any order, so avoid data dependencies between them, such as one path updating a record that another creates.
Call a workflow runs a published, active workflow and can pass the current record in as its input. With Wait? set to true, the flow pauses until the workflow finishes. With false, the flow continues on its own. If the workflow is canceled, or its context record is deleted, a waiting flow stops waiting and carries on. The block returns State, Context, Result and Return value. A workflow on the Requested Item table cannot be selected, so build a flow with a Service Catalog trigger instead. For building a flow from start to finish, see playbooks in Workflow Studio.
Dynamic Flow chooses a flow or subflow at runtime from data. Publish a template, add Dynamic Flow to the parent, select the template, enter the flow name, and supply the inputs. The template’s inputs must match the called flow’s inputs by both Label and Name.
Moving values between blocks and back to a parent
Set Flow Variables assigns values to flow variables that already exist, and those values appear as data pills. Append to Flow Variables adds a value to an array-of-objects flow variable. Assign subflow outputs sets outputs already defined on a subflow. Assignments run from top to bottom, and if an output is set more than once, the last value wins. An assignment can reference any earlier data pill, so the referenced value must come first.
Do not assign subflow outputs inside a loop. The loop cannot read them while the subflow runs and may receive just the final value. Use flow variables for values that change from one pass to the next. For background on subflows themselves, see the subflow guide.
The same scoping rule applies across blocks. A data pill set inside a branch or loop body, such as a Then branch, a decision answer branch, a For Each branch or a parallel path, is available to other actions in that branch. Referencing it from outside produces a null value. Mistakes like this one are covered in common Flow Designer mistakes.
Frequently asked questions
When should I use If instead of Make a decision?
Use If for one or two checks on a record. Use Make a decision when several paths depend on several inputs.
Why does a value set inside an If branch come back empty later?
Data pills set inside a Then branch are available only to actions in that same branch. A step outside the branch receives a null value, so place the step that needs the value inside the same branch.
Can a loop end before its list is exhausted?
Yes. Exit Loop leaves the loop and resumes the flow after it. Skip Iteration moves past the current item. Both sit inside an If branch within the loop.
Does Try stop a flow when an action fails?
No. Try lets the flow continue. The failed action reports Completed (error caught), and the Catch branch runs the fallback steps.