- 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 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 11:22 PM
Hi @swathisarang98 . Thanks very much Swathi. This is great, it is Almost working for me. However, the RITM State is still going to 'Closed Complete' even with this Business Rule in place. I just do not understand why. The Request 'State' is correctly showing as 'Closed Incomplete' but not the RITM, that still stays/remains as 'Closed Complete'. Should I perhaps change the 'order' of the Business Rule, or should I make it After Insert and Update or Before Insert and Update. I am just thinking do I need to change any other conditions perhaps? Could it be conflicting with other Business Rules already existing in the system. I am just not sure why both RITM and REQ State are not both going to 'Closed Incomplete'. Let me know your thoughts/further advice, many thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 11:56 PM
Hi @WazzaJC ,
Try changing the order if it works then fine, otherwise check BR on both request table and RITM table if you find any br with similar condition please send the screenshot ?
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-25-2024 07:10 AM
Thank you very much @swathisarang98 . Thanks to your help & suggested configuration, I have got the functionality to work, many thanks once again ! 🙂