request is still open even the SCTASK's and RITM's are closed

shabbir5
Tera Guru

Hi All,

we have some bulk number of requests are still open even the RITM and SCTASK's are closed

RITM state and stage is closed

and workflow state is showing as finished

can any one let me know the root cause ??

@Ankur Bawiskar 

Thank you,

Shabbir

6 REPLIES 6

Harish KM
Kilo Patron
Kilo Patron

Alternatively you can have this  background script to close all existing requests where RITM are closed

var req = new GlideRecord('sc_request');
req.addActiveQuery();
req.query();
while(req.next()){
    // check if there are any active requested items under it
    var req_item = new GlideRecord('sc_req_item');
        req_item.addQuery('request',req.sys_id);
        req_item.addActiveQuery();
        req_item.setLimit(1);
    if(req_item.next()){
        // do nothing
    }
    else{
        req.state = '3';
        req.active = false;
        req.setWorkflow(false);
        req.update();
    }
    
}

Regards
Harish

John Johnson
Kilo Sage

Where exactly would you put this script?