close multiple catalog tasks when ritm is closed..

latha13
Tera Contributor

HI,

I want to set state as closed complete for all catalog tasks when ritm state is closed complete..This is happens for only 1 catalog item only..

Here i wrote brule on requested item

after ,update

when to run:state changes to closed complete and Item is .....

var reqItem= new GlideRecord('sc_task');
reqItem.addQuery('request_item',current.sys_id);
reqItem.query();
 while(reqItem.next()){

reqItem.setValue('state',3);
 reqItem.update();
 }

Here when i close ritm state only 1 catalog task is closed, after closing 1st task 2nd is opened but not closed it  is in open state....how to achieve?

Thanks in advance...

11 REPLIES 11

Hi Ankur,

I created a BR on sc_req_item table and the above code has helped me.

When I close RITM all the attached CAtalog Tasks are closed as well.

Thanks for your help.

Manthan

RaghavSh
Kilo Patron

"Here when i close ritm state only 1 catalog task is closed, after closing 1st task 2nd is opened but not closed"

From your above statement it seems that when this BR runs there is only one task associated with RITM. ( you can check that in related list of RITM).

In this case only one task will be closed as only one task is associated with RITM at that point of time.

 

 


Raghav
MVP 2023