wait for condition in flow designer

Kalyani35
Tera Guru

Hi experts,

I am using flow designer , in which I need to wait until all the existing response tasks are completed and then move further.

I am using wait for condition action in flow designer ad have written a script for it. But when I check flow execution it shows an error- java.lang.Boolean cannot be cast to java.lang.String

find_real_file.png

This is how the flow looks like currently.

find_real_file.png

script in wait for condition is -

var cnt_task;

var parent_sys_id= fd_data.trigger.current.sys_id;
gs.info('start flow parent_sys_id: '+parent_sys_id)
var gr= new GlideRecord('sn_si_task');
gr.addQuery('parent',parent_sys_id);
gr.addQuery('state','NOT IN','3,4,7');
gr.query();
cnt_task=gr.getRowCount();
if(cnt_task==0)
{
gs.info("inside if cnt: "+cnt_task);
return true;
}
else
{
gs.info("inside else cnt: "+cnt_task);
return false;
}
Thanks in advance!
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

As suggested by Muhammad you will have to change the logic.

You will have to write after update BR on sn_si_task table and mimic an update on sn_si_incident so that flow proceeds once wait for condition evaluates to true

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Allen Andreas
Administrator
Administrator

Hi,

Please use:

answer = true; or answer = false; instead of "return".

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

Thanks for reply.

I tried that way as well, it does not give any error but the flow proceeds further instead of waiting.

Is there anything else I am missing?

You may have missed it when you deleted the commented code but the scripted field only accepts an encoded query to be returned, not a boolean value. 

 

Have a look at some of these options for waiting for child tasks to close in flow

MrMuhammad
Giga Sage

Hi kalyani,

1. "Work for condition" only works for the condition set for the table on which the flow is triggering. i believe your flow is triggering on sn_si_incident and the filter is returning for sn_si_task table that will not work. 

2. As kieran already mentioned, it requires encodedQuery or the value returned for the object/field of the source table.  

Hope that helps!

Regards,

Muhammad

Regards,
Muhammad