Flow designer script on wait for condition not working

cgedney
Giga Guru

I have a flow in which I am creating a REQ/RITM/SCTASK and then trying to wait for all of the tasks on the RITM to complete. Here is the wait for condition I am trying to use:

find_real_file.png

and the script:

var tasks=new GlideRecord('sc_task');
tasks.addQuery('request_item', fd_data._2__create_record.record.sys_id);
tasks.addQuery('state','<',3);
tasks.addActiveQuery();
tasks.query();

if (tasks.next()) {
answer = false;
}
else {
answer = true;
}

 

For whatever reason, it falls through every time. I even tried switching answers to see if that would fix it. It falls through no matter what. 

Here is the flow:

find_real_file.png

Am I missing something? Is there supposed to be another step somewhere?

Thank you,

Charles 

1 ACCEPTED SOLUTION

Balaji Jagannat
Kilo Guru

Hi, 

I see that your "Wait for Condition" is on the Requested Item table, but you are not returning any real filter condition for that table through the script. 

In your step#3, you are creating some task, is that the task associated with RITM or something else? I'm trying to see whether you can set your "Wait for Condition" on the sc_task table itself an avoid the need to script?

 

View solution in original post

16 REPLIES 16

HI,

Even if we create the Wait for condition on SC Task we need to update something on RITM to allow the context to evaluate the wait for condition again


Thanks,
Ashutosh

Hi Ashutosh - I assuming that we will remove the "wait for condition" on RITM and keep it only on "sc_task", if its possible for the given requirement. 

 

can you help me understand why you think, we need to do "wait for condition" on RITM again?

Hi,

We have to test this. Because i tried may be i am wrong but it was waiting on that step only event if i update the Task.


Thakns,
Ashutosh

I scrapped the script and decided to use the conditions on the sc_task.

find_real_file.png

This seems to work the best for me.

Thank you Balaji

cgedney
Giga Guru

Thank you all for the excellent suggestions.