when i close first task- RITM automatically closed but still remain SCTasks are open

Kishor Mudhili
Giga Guru

hello Team,

 

as per my requirement, for each catalog item, several tasks should be created. so I'm using paralell flow.

 

if i closed first task - then 2 tasks should be created. once 2 tasks closed then remain 2 tasks should be created.

it's working as i expected but when close 1st task - related RITM automatically closed but still remain SCTask open.

please find my flow. it's happend only for this flow. please suggest how we can reproduce the issue.

 

KishorMudhili_0-1669824256117.png

 

3 ACCEPTED SOLUTIONS

Hi @Kishor Mudhili 

 

Sorry for delay response due to unavailiability.

 

Please try below code once:

 

var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item',current.request_item);
tasks.addQuery('state', '!=' , '3');
tasks.query();
if(tasks.hasNext())
{
current.setAbortAction(true);
} else {
var rq = new GlideRecord('sc_req_item');
rq.addQuery('sys_id',current.request_item);
rq.query();
if(rq.next())
{
rq.state = 3;
rq.update();
}
}

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

View solution in original post

thank you Saurav,

 

i have added if condition before task gliderecord it's working now. but if add in " CONDITION" it's not working .

 

 

 

View solution in original post

Hello,

 

If my answer helped you can you also mark it as correct.

 

Thanks.

View solution in original post

10 REPLIES 10

Hi @Kishor Mudhili 

 

Sorry for delay response due to unavailiability.

 

Please try below code once:

 

var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item',current.request_item);
tasks.addQuery('state', '!=' , '3');
tasks.query();
if(tasks.hasNext())
{
current.setAbortAction(true);
} else {
var rq = new GlideRecord('sc_req_item');
rq.addQuery('sys_id',current.request_item);
rq.query();
if(rq.next())
{
rq.state = 3;
rq.update();
}
}

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

hi Anubhav,

 

no luck, still same issue with above code also..

Saurav11
Kilo Patron
Kilo Patron

Hello Kishor,

 

I believe this is because of the parallel flow you are using. As the RITM is probably gets closed before the task is even created.

 

In the BR add the condition in the filter that item is not the above one. So the BR will not run for this flow.

 

And in this flow at the end add  a new action update RITM and update the RITM to close complete.

 

Please mark my answer as correct based on Impact.

thank you Saurav,

 

i have added if condition before task gliderecord it's working now. but if add in " CONDITION" it's not working .

 

 

 

Hello,

 

If my answer helped you can you also mark it as correct.

 

Thanks.