How to Close RITM only after catalog tasks are closed

Joshuu
Kilo Sage

Hi All,

 

I have a catalog item workflow as below. Here the catalog tasks will be triggered through Run Script activity. And the issue is that the RITM is getting completed as soon the catalog tasks are created.

 

I want the RITM to get completed only after all the catalog tasks are Closed Complete.

 

priyarao_0-1674070620789.png

 

Please assist me.

 

Thanks,

Priya.

 

 

1 ACCEPTED SOLUTION
2 REPLIES 2

Pooja58
Kilo Sage

Hi,

In your workflow, before X= set values activity, add one more activity called wait for condition, where you check the sc_tasks under this RITM are closed or not. you can refer below code and do some modifications.

var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.addQuery('active', true);
gr.query();
if(gr.hasNext())

{
answer = false; // returning false as sc_tasks are active
}
else

{
answer = true; // Return true when no active sc_tasks
}

you can check if answer returning as true then close the RITM.