- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 06:05 PM
We have order guide requests from the past that did not close properly because the RITM stages were never set to completed in the workflow. The workflows have since been fixed.
I'm thinking the script would need to check that all tasks associated with an RITM are inactive, then set the RITM stage to completed. I'm hoping that this can be done without sending out notifications when the request closes.
If the RITM stage is set to complete, the OOB business rule should trigger and close out the parent request.
Can anyone help with the script, or maybe provide a better alternative?
Thank you,
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2021 08:57 PM
Glad to know that my script helped.
You can additional filter conditions for your query to only select particular catalog item's RITM
updateRecords();
function updateRecords(){
try{
var itemNames = 'Catalog Item1,Catalog Item2'; // give your catalog item names here
var ritm = new GlideRecord("sc_req_item");
ritm.addActiveQuery();
ritm.addEncodedQuery("stage!=complete");
ritm.addEncodedQuery('cat_item.nameIN', itemNames);
ritm.query();
while(ritm.next()){
//check for active sc tasks
var taskRec = new GlideRecord('sc_task');
taskRec.addActiveQuery();
taskRec.addQuery("request_item",ritm.sys_id);
taskRec.query();
if(!taskRec.next()){
//close requested item
ritm.stage = "complete";
ritm.active = false;
ritm.state = 3; // set to close complete
ritm.setWorkflow(false); // stop any BR
ritm.update();
//close request
var request = ritm.request.getRefRecord();
request.active = false;
request.state = 3;
request.setWorkflow(false);
request.update();
}
}
}
catch(ex){
gs.info('Exception'+ex);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 03:54 AM
Hi Ankur
It's working fine for the stage update with in the form but if I go check in list view stage fields in the blue color.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 05:58 PM
CAN I PLEASSE GET MORE INSTRUCTIONS WHERE TO ADD THIS SCRIP TO ?