Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trigger approval after all Catalog Tasks get closed in Flow Designer

Aaviii
Tera Contributor

Hi, in my scenario multiple catalog tasks are getting created from List collector variable. I have a requirement to trigger approval once all catalog tasks gets closed. I have attached SS of flow.

Utkarsh4_0-1716363556180.png

 

1 REPLY 1

Kavita_Bhojane
Tera Guru

Hi @Aaviii 

 

Here are the details steps:

Create an action to check open tasks in RITM

1. Define input to accept RITM sys_id.

2. Add a script to check open tasks and define script output of type "True/False" :

 

(function execute(inputs, outputs) {
// ... code ...

outputs.open = hasOpenTasks(inputs.ritm);
function hasOpenTasks(sysId) {
var numOpenTasks;
var rec = new GlideAggregate('sc_task')
rec.addQuery('request_item', sysId);
rec.addQuery('active', true);
rec.addAggregate('COUNT');
rec.query();
if(rec.next()){
numOpenTasks = Number(rec.getAggregate('COUNT'));
}
return numOpenTasks > 0;
}
})(inputs, outputs);

 

3. Define Output variable of type "String" and assign script output to this variable.

4. Save and Publish the action

5. Call this action in your flow and give RITM sys_id as input.

6. Check if action output is false and ask for approval.

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

Thanks,
Kavita Bhojane