How can we close RITM when all the catalog task is closed for that item?

Surbhi16
Tera Contributor

Hi All,

How can I close the RITM when all the catalog task are changes to closed using business rule

Thanks
Surbhi

1 ACCEPTED SOLUTION

@Surbhi 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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

View solution in original post

12 REPLIES 12

kunal20
Kilo Guru

Hi Surbhi,

You can use this code to close The RITM when all sc_tasks are closed:-

var grCatTask = new GlideRecord('sc_task');
grCatTask.addQuery('request_item', current.sys_id);
grCatTask.query();

while(grCatTask.next()){
      if(grCatTask.state != 3){  
      gr.query();
      if(!gr.next()){
      var gritem=new GlideRecord('sc_req_item');
      gritem.addQuery('sys_id',current.request_item);
      gritem.query();
      if(gritem.next()){
        gritem.state='3';
}
    gritem.update();         
}
      answer = false;  
      }

}

Thank you,

Kunal

Surbhi16
Tera Contributor

Thanks Kunal!!

But its not working

Regards

surbhi

Sagar Pagar
Tera Patron

Hi,

You have to write after update business rule on sc_task table. where you have to check the RITM and its other catalog tasks are closed or not.

IF all are closed then mark the RITM as closed.

 

Thanks,
Sagar Pagar

The world works with ServiceNow

Thanks Sagar!!

But I want Script

Thanks