Skip to content

Commit 386f6a3

Browse files
authored
Create script.js
1 parent 1106276 commit 386f6a3

File tree

1 file changed

+28
-0
lines changed
  • Server-Side Components/Business Rules/Trigger Flow

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//Trigger flow from Business rule
2+
//Flow can be triggered in foreground or in background
3+
/*Triggering automated workflows after record creation or update.
4+
Passing dynamic data to flows for processing (e.g., notifications, approvals, integrations).
5+
Improving performance by running flows asynchronously.*/
6+
7+
(function executeRule(current, previous /*null when async*/ ) {
8+
current.state = 1;
9+
(function() {
10+
11+
try {
12+
var inputs = {};
13+
inputs['current'] = current; // GlideRecord of table:
14+
inputs['table_name'] = '<table name>';
15+
16+
// Start Asynchronously: Uncomment to run in background.
17+
sn_fd.FlowAPI.getRunner().flow('<flow name>').inBackground().withInputs(inputs).run();
18+
19+
// Execute Synchronously: Run in foreground.
20+
// sn_fd.FlowAPI.getRunner().flow('<flow name>').inForeground().withInputs(inputs).run();
21+
22+
} catch (ex) {
23+
var message = ex.getMessage();
24+
gs.error(message);
25+
}
26+
27+
})();
28+

0 commit comments

Comments
 (0)