Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Server-Side Components/Business Rules/Trigger Flow/read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Trigger flow from Business rule
Flow can be triggered in foreground or in background
Triggering automated workflows after record creation or update.
Passing dynamic data to flows for processing (e.g., notifications, approvals, integrations).
Improving performance by running flows asynchronously.
28 changes: 28 additions & 0 deletions Server-Side Components/Business Rules/Trigger Flow/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//Trigger flow from Business rule
//Flow can be triggered in foreground or in background
/*Triggering automated workflows after record creation or update.
Passing dynamic data to flows for processing (e.g., notifications, approvals, integrations).
Improving performance by running flows asynchronously.*/

(function executeRule(current, previous /*null when async*/ ) {
current.state = 1;
(function() {

try {
var inputs = {};
inputs['current'] = current; // GlideRecord of table:
inputs['table_name'] = '<table name>';

// Start Asynchronously: Uncomment to run in background.
sn_fd.FlowAPI.getRunner().flow('<flow name>').inBackground().withInputs(inputs).run();

// Execute Synchronously: Run in foreground.
// sn_fd.FlowAPI.getRunner().flow('<flow name>').inForeground().withInputs(inputs).run();

} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}

})();

Loading