Notifications

10 views

Symptoms


When starting workflow off cmdb_ci from script the workflow had an error "execute was aborted - bad ActiveContext=" and will not move unless "nudged"

Sample code:

var query = 'operational_status=2^sys_class_name=cmdb_ci_server';
var gr = new GlideRecord('cmdb_ci');
gr.addEncodedQuery(query);
gr.query();

while (gr.next()) {
var wf = new global.Workflow();
wf.cancel(gr);
wf.deleteWorkflow(gr);
var context = wf.startFlow('e26dc8654f01efc06f4d3e1ca310c767', gr, 'update'); //sys_id of workflow
var wf2 = new global.Workflow();
wf2.broadcastEvent(context.sys_id.toString(),'');
}

Release


Kingston

 

Cause


Workflow context is technically on child table (cmdb_ci_server) so engine refuses to run the flow.

Resolution


Revise the line calling startFlow like below:

wf.startFlow('e26dc8654f01efc06f4d3e1ca310c767', new GlideRecordUtil().getCIGR(gr.getUniqueValue()));

Additional Information


https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideRecordUtil/concept/c_GlideRecordUtilAPI.html

Article Information

Last Updated:2018-11-26 10:03:10
Published:2018-10-24