Article - Calling Flow Designer Flows from a Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited an hour ago
Calling Flow Designer Flows from a Business Rule
ServiceNow Flow Designer provides a low-code way to automate processes, but there are scenarios where a flow needs to be triggered from custom server-side logic. In such cases, FlowAPI can be used to invoke an existing flow directly from a Business Rule.
Generate the FlowAPI Code
Open the required flow in Flow Designer → ⋮ → Create Code Snippet.
ServiceNow generates the required FlowAPI code, including the flow's internal name and configured inputs.
try {
var inputs = {};
inputs['current'] = current;
inputs['changed_fields'] = changedFields;
inputs['table_name'] = 'change_request';
sn_fd.FlowAPI.getRunner()
.flow('global.my_flow')
.inForeground()
.withInputs(inputs)
.run();
} catch (ex) {
gs.error(ex.getMessage());
}Passing Flow Inputs
Populate the inputs object with the values required by the flow.
inputs['current'] = current; inputs['changed_fields'] = changedFields; inputs['table_name'] = 'change_request';
The input names must match the inputs configured in Flow Designer.
Finding the Flow Internal Name
The .flow() method requires the flow's internal name, for example:
.flow('global.my_flow')You can identify the internal name through the flow's captured update record or by using SN Utils → /xml and searching for internal_name.
Foreground vs Background
Foreground – waits for the flow execution:
.inForeground()
Background – starts the flow asynchronously:
.inBackground()
Use background execution when the Business Rule does not need to wait for the flow to complete.
Conclusion
Using FlowAPI allows you to keep the Business Rule responsible for when the automation should run, while Flow Designer handles the automation itself. This avoids duplicate logic and makes the overall solution easier to maintain.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello @rohanaditya ,
Thanks for sharing this here . You can add prefix like blog or article in heading , so other users can identifies this is informative article/blog not question .