RITM State/Stage is not getting updated

MDRaheem
Mega Contributor

I am working in ServiceNow (FSO scope) inside a widget and trying to update the RITM state to "Request Cancelled" via script (mentioned below)

The flow context state changes to Cancelled when I run it in Background Script, but the RITM record itself does not update. Additionally, work notes are not being updated.

Could someone help me understand why the RITM state and stages are not updating?



Script:

var flowContext = new GlideRecord('sys_flow_context');
flowContext.addEncodedQuery("source_record="+get_ritm_sys_id+"^stateNOT INCOMPLETE,CANCELLED");
flowContext.query();
if(flowContext.next()) {
gs.info(flowContext.getValue("name"));
flowContext.state = 'CANCELLED';
flowContext.update();
}

var grRITM = new GlideRecord("sc_req_item");
grRITM.getEncodedQuery("sys_idSTARTSWITH"+get_ritm_sys_id);
grRITM.query();
if(grRITM.next()){
grRITM.setWorkflow(false);
grRITM.autoSysFields(false);
grRITM.state = "8";
grRITM.stage = "request_cancelled";
grRITM.update();
}

0 REPLIES 0