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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-07-2022 07:19 AM
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.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-07-2022 08:44 AM
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
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-07-2022 06:55 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-07-2022 07:03 PM
Hi,
use this to query
fd_data.trigger.current.request_item
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-07-2022 09:15 PM
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();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-09-2022 03:43 AM
Hi
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