Bulk close all REQ's with no RITM's attached

Alex Saager1
Tera Contributor

Hi Community,

I've recently found that we have 289 requests in our instance with no RITMS attached (not sure how this happened) and am trying to bulk close these as there's no use for them.

When looking at the request table I cannot find anything on the filter relating to related lists (screenshot below) to show REQ's with no RITM so am wondering on how best to get these closed off.

AlexSaager1_0-1729591457864.png

 

Many thanks,

Alex

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron
2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

Hi Alex,

 

Check this. Similar Question is answered there.

Solved: Re: How do I filter on REQs to show REQs with no r... - Page 4 - ServiceNow Community

-Anurag

Voona Rohila
Mega Patron
Mega Patron

HI @Alex Saager1 

You can create a report on REQ Table and add Related List Filter to get all the Requests with no ritm's attached list.

VoonaRohila_0-1729594465655.png

 

 

Write a fix script to close the Requests with NO RITM's.

var grScRequest = new GlideRecord('sc_request');
grScRequest.query();
while (grScRequest.next()) {
    var grScReqItem = new GlideRecord('sc_req_item');
    grScReqItem.addEncodedQuery("request=" + grScRequest.sys_id);
    grScReqItem.query();
    if (!grScReqItem.hasNext()) {
        //update req state here.
        grScRequest.request_state = 'closed_skipped'; //change state value
        grScRequest.update();
    }

}

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP