Flows begin with an Event. Often that event will be tied to an application (e.g. new records in Salesforce). This topic covers two alernatives: A Schedule event or a Child Flow event.
Child Flow
A “Child Flow” event is used for a Flow that runs when called by another Flow.
This is useful when:
- You have a series of steps that get used more than once in a single Flow or across multiple Flows. Moving them into their own “child Flow” lets you create them once and then reuse them repeatedly. You run the steps from other Flows by using Call Flow or Call Flow Async.
- You want to process a list, one item at a time. For instance, you can run a series of steps on each list item using For Each or you can transform a list into a new list (one item at a time) using Map.
- Or, if you just want to break a very large Flow into smaller, more manageable parts.
Each Child Flow card has the following outputs:
- Inputs to this Flow
- Click to create custom fields, one at a time. Give each a name and data type (such as Text or Number). Each custom field you create corresponds to an expected input from any Flow that calls your child Flow.
- Context - the outputs in this section are automatically assigned values every time the Flow runs:
- Index - This number output is assigned a value when the Flow is called from a function that loops through the items of a list (e.g. a For Each or Map function). The value of _Index_ corresponds to the item’s position in the list (starting with zero) processed by this particular instance of the Flow.
- Caller - The keys of the Caller object tell you which Flow called the child Flow (id and name), which particular execution of the Flow made the call (_executionid), and which particular step in the Flow (method, which is an unique ID). When the child Flow is manually run, then id and _executionid are null. This is especially useful for debugging purposes.
- Error - This object output is assigned a value when the Flow is called for Error Handling. The value of Error corresponds to the raw error object returns by the application or action that caused the error – e.g. an object that will often have keys that include “message”, “statusCode” and “execution” (the unique identifier of the Flow execution that caused the error, which can be used to construct a URL to the execution history that shows the Flow details that led to the error).
- Execution ID - the unique ID of the Flow instance.
Note: A Child Flow must be turned on before it can be called by other Flows.
Scheduled Flow
A “Scheduled Flow” event is used for a Flow that runs according to a schedule, such as once an hour, 5pm on Fridays, or at 9am on the first day of every month.
Adding a Scheduled Flow event prompts you to provide the schedule details. You can change the schedule by clicking the clock icon at the bottom of the card. (Note: You can similarly adjust the schedule of most application events. For instance, you can set a Salesforce - New Record event to check for new records every Friday at 5pm rather than every 5 minutes.)
The schedule goes into effect only after the Flow has been turned on.
Each Scheduled Flow card has the following outputs:
- Current Time - the date and time that the current instance of the Flow was initiated (in ISO UTC format). This can be passed to any text or date & time input.
- Execution ID - the unique ID of the Flow instance.