Wait for condition Script in workflow

Madhuchhanda
Tera Expert

Hi all,

I have wait for condition and it should work when the status is 'closed complete' or 'closed incomplete' or 'closed skipped'. But my script is not working and my tasks are in parallel. But I can't use join.

Below is my script :-

checkCatalogTasks();

function checkCatalogTasks() {

var grTask = new GlideRecord('sc_task');

            var Task = gr.addQuery('request_item', current.sys_id);

            Task.addOrCondition('active', true);

            Task.addOrCondition('state', '!=', '3');

            Task.addOrCondition('state', '!=', '4');

            Task.addOrCondition('state', '!=', '7');

grTask.query();

if(grTask.hasNext()){

answer = false;

}

else{

answer = true;

}

}

Please help. Thanks in advance.

7 REPLIES 7

Thanks but I have already tried it.

Priyanka Chaudh
Giga Contributor

Hi Madhuchhanda.

 

Just a small change in your script and it should work.

Script

var query = 'active=true^ORstateIN3,4,7'
var grTask = new GlideRecord('sc_task');

grTask.addQuery('request_item', current.sys_id); // u were using gr here instead of grTask

grTask.addEncodedQuery(query); // simplified filter conditions

grTask.query();

if(grTask.hasNext()){

answer = false;

}

else{

answer = true;

}

 

 

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.

 

Thanks,

Priyanka

Trupti6
Tera Expert

 

Hi,

Please check below screenshot and check,

 

find_real_file.png

Thanks,

Trupti S.