Blog

Wait for Catalog Tasks to Complete

In workflow on catalog task creation, you can always specify "Wait for completion" to have catalog tasks wait to close until moving on in the work.  You can also use a "Join Activity" to wait for tasks as well.

Sometimes you don't want to do that or it doesn't work for you.  Possibly you want to do other activities and wait at a later point in the workflow.  Here is a script useful for checking if catalog tasks are complete in a workflow.

Workflow Activity: Wait for Catalog Tasks to Complete
Condition Script:
checkCatalogTasks();
function checkCatalogTasks() {
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item', current.sys_id);
grTask.addQuery('active', true);
grTask.query();
if(grTask.hasNext()){
answer = false;
}
else{
answer = true;
}
}