RITM State/Stage is not getting updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
44m ago
Hi @MDRaheem ,
Why by custom script instead of holding the logic within the flow
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
