Flow designer creating 2 tasks one after other but the other flow is closing the RITM.

Community Alums
Not applicable

Hi,

We have a catalog item which has a flow to create 2 tasks one after the other which is working as expected from flow. the challenge here is we have a flow in flow designer which will run on the SCTASK for all the items to see if there are inactive Tasks close the RITM(this ability was developed because few users create manual tasks). So now for the new catalog item when the first task is completed RITM is setting the state to closed and then the 2nd task is getting created.

 

@Ankur Bawiskar Is there any way to achieve this?

Thanks in advance

9 REPLIES 9

like this

var gr1 = new GlideRecord('sc_task');
gr1.addQuery('request_item', fd_data.trigger.table_name.request_item);
gr1.addEncodedQuery('stateNOT IN3,4,7');
gr1.setLimit(1);
gr1.query();
return !gr1.hasNext();

Regards
Ankur

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

Community Alums
Not applicable

@Ankur Bawiskar I tried to add this script in the Wait for condition on the global flow where we are checking if there is any active tasks don't close the RITM but i am getting this error "java.lang.Boolean cannot be cast to java.lang.String".

 

Please let me know if i am doing anything wrong. attached is the flow which will check if there are any active tasks and if count is 0 it will close the RITM. I added a wait for condition in Line 2 as per attached.find_real_file.pngfind_real_file.png

Hi,

use this to query

fd_data.trigger.current.request_item

Regards
Ankur

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

Community Alums
Not applicable

@Ankur Bawiskar No luck still the same error message.

 

I tried checking the BR (after update) But here i am not sure how to check if the current Flow is still running or completed.

var gr1 = new GlideRecord('sc_task');
gr1.addQuery('request_item', current.request_item);
gr1.addEncodedQuery('stateNOT IN3,4,7');
gr1.query();
var totalTasksCompleted = gr1.getRowCount();
if(totalTasksCompleted == 0){
var ritmRec = new GlideRecord('sc_req_item');
ritmRec.get(current.request_item);
ritmRec.state = 3;
ritmRec.stage = 'complete';
}

ritmRec.update();

Community Alums
Not applicable

Hi @Ankur Bawiskar  i have achieved the above requirement from flow designer, but facing an another challange.

1. Trigger when task is updated

2. Look up task record when Request item is Catalog request item and Active is True.

3. if count is 0

3. Look up sys_flow_context table and fetch the source records and state is completed

4. If count is 0 the i am updating the request item.

 

The other requirement on this one is to find the last task closed and update the SCTASK state to RITM... could you please help me to achieve this one. 

Can we do it using the flow designer? if yes, could you please help me on how to do it and where to add the condition

find_real_file.png