- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2018 08:01 AM
Hi Team,
I am trying to trigger workflow from Business rule and pass values to workflow variable from Business rule. I used the syntax from below link . Workflow got triggered successfully but values are not getting assigned to workflow variables.
Ref URL : https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/using-workflows/concept/c_UsingVariablesInAWorkflow.html#ariaid-title3
Business Rule on sc_req_item table :
startWorkflow(current.cat_item.workflow);
action.setRedirectURL(current);
function startWorkflow(id) {
gs.addInfoMessage("G U_SCCM_Device :"+current.u_sccm_device);
var w = new Workflow();
var vars = { } ;
vars.device = "ggg123" ;
vars.install_user_group = "input_var_value2" ;
vars.g_dev_1 = "test124" ;
//var context = w.startFlow(id, current, current.operation('update'),{device: "test124" });
//var context = w.startFlow(id, current, current.operation('update'),{g_dev_1: "g_dev_124" });
var context = w.startFlow(id, current, current.operation('update'),vars);
//var context = w.startFlow(id, current, current.operation('update'), getVars());
if (context != null)
current.context = context.sys_id;
//gs.addInfoMessage("GGG Inside Business Rule 123 :"+context);
gs.addInfoMessage("GGG getVars() :"+ getVars());
}
/**
* 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 = {};
vars.device = "ggg123";
vars.g_dev_1 ="g_test1234";
// gs.addInfoMessage("GGG vars.device:"+ vars.device);
// for (var n in current.variables)
//vars[n] = current.variables[n];
return vars;
}
Regards,
Manoj Nagarajan
Solved! Go to Solution.
- Labels:
-
Field Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 10:09 AM
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("Business Rule started for Ping Host");
gs.log('workflow started for Failed Ping Events');
var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('workflow name'), current, 'update');
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 10:09 AM
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("Business Rule started for Ping Host");
gs.log('workflow started for Failed Ping Events');
var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('workflow name'), current, 'update');
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 11:19 AM
simply create an event and call it from BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 05:59 PM
how to call event from BR??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2018 12:09 PM
How are you trying to access the variables from within the workflow? Have the variables been defined in the workflow you are trying to use?
Also, have you seen this article that was linked to from the page you listed? It might prove useful.
https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/using-workflows/concept/c_WorkflowCatalogVariables.html