The Zurich release has arrived! Interested in new features and functionalities? Click here for more

auto close ritm

Sarabjeet1
Tera Contributor

Hi,

 

I need to set a rule for auto closing RITMs after 3 days of resolving. Below is the BR i am using. Please let me know why is it not working.

 

(function executeRule(current, previous /*null when async*/) {

autoCloseRequest();

function autoCloseRequest() {
    var ps = gs.getProperty('glide.ui.autoclose.time'); // property value set to 3
    var pn = parseInt(ps);
    var queryTime = new GlideDateTime();
    queryTime.addDaysUTC(-pn);

    if (pn > 0) {
        var gr = new GlideRecord('sc_req_item');
        gr.addQuery('state', '10');
        gr.addQuery('sys_updated_on', '<', queryTime);
        gr.addQuery('u_coh', 'false');
        while (gr.next()) {
            gr.state = '50';
            gr.comments = 'Request ditutup otomatis setelah ' + pn + ' hari dari tiket diselesaikan.';
            gr.active = false;
            gr.update();
        }
    }
}

})(current, previous);
1 ACCEPTED SOLUTION

Hi,

Have you created the schedule job to trigger your script?

Like below:

Navigate to sys_trigger table list and search for Autoclose Incident job.

 

Screenshot 2024-01-03 at 4.47.21 PM.png

 

replace name of your BR in the Job Context.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

7 REPLIES 7

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Sarabjeet1 

 

RITM will get auto closed once the related Catalog task get closed. Not sure why you are writing BR to close after 3 days.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@Sarabjeet1 

RITM is not something like INC which will get closed after resolution. RITM is regarding fulfilling a request.

RITM can set to close complete once all catalog tasks are completed. If this is not happening then write your custom logic

You should implement this as RITM OOB doesn't show the close or resolve state values.

 

AnkurBawiskar_0-1704282265953.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Thanks for your response but RITM states are customized as per requirement and auto closing them after 5 days of moving it to resolved is also a part of requirement.