- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 02:12 PM
Business Rule to Set RITM & Request State to Closed Incomplete when RITM Stage is Request Cancelled
Hi ServiceNow Community colleagues,
Please can I ask for your advice on the Business Rule I would need to configure the following:
I would like to set the Requested Item (RITM) and Request 'State' to 'Closed Incomplete' after the RITM 'Stage' = Request Cancelled. The Request 'Stage' is currently being set to Request Cancelled in a Flow, but I want a business rule outside of the Flow, to auto-set the RITM and REQ State to Closed Incomplete.
So as soon as the RITM 'Stage' is = 'Request Cancelled', I want the Business Rule to set the RITM 'State' to 'Closed Incomplete' and also the corresponding Service Request 'State' to 'Closed Incomplete'.
Would anyone kindly be able to share the Script and Conditions I need to configure for this Business Rule - how would it look?
Thanks very much as always.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 03:21 PM - edited ‎02-22-2024 10:30 PM
Hi @WazzaJC ,
You can Try after update BR
Table: sc_req_item
condition as shown below,
Note: better to keep your catalog item in condition so that it will not run for others,
In action, to update requested item state
In advanced, to update Request table
code
(function executeRule(current, previous /*null when async*/) {
var reqUpdate = new GlideRecord('sc_request');
reqUpdate.addQuery('sys_id',current.request);
reqUpdate.query();
if(reqUpdate.next()){
reqUpdate.state = 4 ;
reqUpdate.request_state = 'closed_cancelled';
reqUpdate.update();
}
})(current, previous);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 05:14 PM
Hi @WazzaJC there is OOB BR which does it when you cancel the RITM, Please check this BR on req item table
Close Parent if Required
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 05:14 PM
Hi @WazzaJC there is OOB BR which does it when you cancel the RITM, Please check this BR on req item table
Close Parent if Required
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 05:17 PM
Hi @WazzaJC, We have a OOO Business rule 'Close Parent if Required' which handles the closure of parent based on the stage of RITM. Have you checked / tested this? If the OOB script is not working as per the need, then you can try the script shared by @swathisarang98 but just correct the line 6 as reqUpdate.next()
if(reqUpdate.next()){
Regards,
Sunil