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

Sam Ogden
Tera Guru

Hi Latha,

I'm guessing that when you close the RITM there is only a single sctask linked.  On closing this sctask via the BR it is then moving to the next activity in the workflow which is then creating the second sctask.  In your BR you need to also cancel the workflow.  You can refer to this article around how to script this.

I hope this helps, if so please mark as helpful or correct

Thanks

Sam

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I assume this BR is on sc_req_item table

the above code should work fine

Is some task getting created when RITM is closed?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

HI Ankur,

In RITM i want to show 2 tasks closed complete..

if i use new Workflow().cancel(current); only 1 catalog task complete and stop workflow..

but i want to show 2 catalog tasks completed in ritm(through wf)

Thanks...