How to trigger a workflow from a business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2011 12:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2011 03:26 PM
If you look at the Business Rule titled Start Workflow (sc_req_item), it gives some hints.
startWorkflow(current.cat_item.workflow.toString());
function startWorkflow(id) {
var w = new Workflow();
var context = w.startFlow(id, current, current.operation(), getVars());
if (context != null)
current.context = context.sys_id;
}
/**
* Get the variables from the request item so that we can map these to the workflow.input
* variables if the names match.
*/
function getVars() {
var vars = {};
for (var n in current.variables)
vars[n] = current.variables[n];
return vars;
}
It looks like all it wants is this:
var w = new Workflow();
var context = w.startFlow(id, current, current.operation(), variable_map);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2018 03:32 PM
didn' t worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2023 12:46 AM
Hello @tyler_jones ,
As you suggested, i have used the below line,
Could you please tell me, how to use the "variable_map" in workflow.
var context = w.startFlow(id, current, current.operation(), variable_map);
For example:
var vars = { "number" : "5" }
var context = w.startFlow(id, current, current.operation(), vars); // passing vars obj to Workflow.
How to access the "number" property in Workflow, please suggest the syntax.
Thanks in Advance,
Hariharan N
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2018 03:33 PM
(function executeRule(current, previous /*null when async*/) {
var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('wf_name'), current, 'update');
})(current, previous);