Calling a subflow from a business rule

JLeong
Mega Sage

Hi,

I am trying to call a subflow from a business rule but it doesn't work. Could someone please check what I am missing.

I am running the business rule on after update and this is the code snippet:

(function executeRule(current, previous /*null when async*/) {
try {
var inputs = {};
inputs['user'] = current.sys_id; // GlideRecord of table: sys_user
inputs['curr_location'] = current.location; // GlideRecord of table: cmn_location
inputs['prev_location'] = previous.location; // GlideRecord of table: cmn_location

// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
// sn_fd.FlowAPI.startSubflow('global.move_assets_on_location_change', inputs);

// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var outputs = sn_fd.FlowAPI.executeSubflow('global.move_assets_on_location_change', inputs);

// Current subflow has no outputs defined.
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}

})(current, previous);

 

Thank you!

2 REPLIES 2

Punit S
Giga Guru

Hi Jleong, 

 

Following can be useful for your case . You can call workflow/subflow using below code. 

I would suggest to check the compatibility with your current version . 

 

var gr = new GlideRecord('wf_workflow');
gr.addQuery('name', 'Restart Linux Server');
gr.query();
if (gr.next()) {
var wf = new Workflow();
var workflowId = '' + gr.sys_id;
var vars = {};
wf.startFlow(workflowId, current, current.operation, vars);
}
action.setRedirectURL(current);

Please hit useful/like if this helps

Thanks,
Punit

Hi Punit,

Thanks for replying to my question. I was calling a flow designer subflow. 

Appreciate your help.

Regads,