- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 12:28 AM
Hi,
Once the RITM is closed the REQ is not closing.
RITM's having tasks or workflows are involved REQ is getting closed correctly.
But the RITM's where tasks are not there REQ form is not getting closed.
Help?
Thanks,
Vaishnavi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 03:26 AM - edited 06-30-2023 03:30 AM
Hi @Vaishnavi35 ,
try this
(function executeRule(current, previous /*null when async*/ ) {
var grReq = new GlideRecord('sc_request');
grReq.addQuery('sys_id', current.request);//get the request from RITM
grReq.query();
if (grReq.next()) {
grReq.request_state = 'closed_complete'; //add your field name
grReq.update();
}
})(current, previous);
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 01:57 AM - edited 06-30-2023 03:31 AM
Hi @Vaishnavi35 ,
you can create the After Business rule on sc_req_item table and give condition as state changes to close complete. Use below script
(function executeRule(current, previous /*null when async*/ ) {
var grReq = new GlideRecord('sc_request');
grReq.addQuery('sys_id', current.request);//get the request from RITM
grReq.query();
if (grReq.next()) {
grReq.request_state = 'closed_complete';
grReq.update();
}
})(current, previous);
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 02:33 AM
Hi Pavan,
The code does not work as the REQ record is still active even after the RITM state is moved to closed complete.
Thanks,
Vaishnavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 03:26 AM - edited 06-30-2023 03:30 AM
Hi @Vaishnavi35 ,
try this
(function executeRule(current, previous /*null when async*/ ) {
var grReq = new GlideRecord('sc_request');
grReq.addQuery('sys_id', current.request);//get the request from RITM
grReq.query();
if (grReq.next()) {
grReq.request_state = 'closed_complete'; //add your field name
grReq.update();
}
})(current, previous);
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 04:02 AM
@Pavankumar_1 why going for a workaround and not for the out-of-the-box business rule?
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 02:04 AM - edited 06-30-2023 02:07 AM
Hi there,
Out-of-the-box this should work fine. I see in other replies in this topic something with a custom business rule. Nice workaround, though why? I would try to find the actual cause. Because again, out-of-the-box this should work fine.
Are you experiencing this for one workflow specific? Or for all?
Kind regards,
Mark
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field