Closing Bulk RITM and SCTASK with update of additional comments on RITM - Interview question

ServiceNow10sun
Giga Guru

Hi All, 

 

Basic  Interview script :

 

If we want to close `bulk RITMs when the condition is static (Encoded query)  and its associated sctasks then we can use this script. If flow designer is option then we can use  this background script:

 

var ritm = new GlideRecord('sc_req_item');
ritm.addEncodedQuery('assignment_group=39a4afd01b1d5910d9161f46b04bcb55^assigned_toISEMPTY^state=1^cat_item=10a3fb1a1bb43550c3b51f46b04bcb10'); // Encoded query copy from the filter
ritm.setLimit(5);
ritm.query();
 
while (ritm.next()) {
    ritm.comments = "Closed skipped RITM";
    ritm.update();
 
    var sc = new GlideRecord('sc_task');
    sc.addQuery('request_item', ritm.sys_id);
    sc.query();
   
    if (sc.next()) {
        sc.state = 7;
        //sc.work_notes = "Closed skipped SCTASK";
        sc.update();
       
        gs.info("The closed SCTASK is " + sc.number);
        gs.info(" sc_req_item: " + ritm.number);
    }
}

 

 

1 REPLY 1

Murthy Ch
Giga Sage

Hi @ServiceNow10sun 

If you are trying to share the information or content. Please create articles in different forum.

Thanks,
Murthy