Wait for condition getting cancelled everytime the condition meets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 07:19 AM
Hello experts,
i Have a workflow and inside that workflow i have a wait for condition activity. Please find the code snippet below:
//START
//END
What is the script doing:
We have a table called "u_vm_automation_scheduler" and we have a status field which is originally in "ready" state. In my wait for activity, i am making the workflow to wait untill and unless the status field is Success or Error.(Script above). Whenever the Status becomes Success or Error, the Workflow rather than moving forward, it is getting cancelled everytime. Till the time the status field is ready , the Wait for condition is waiting but as soon as the condition is meeting for sucess or error the workflow is instantly getting cancelled. Can anyone tell me what i am doing wrong.
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 07:28 AM
Hi,
Why you are using script?
Instead use condition builder and put the condition like below:
Status IS Success <OR> Status is Error
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 07:30 AM
The workflow is built in ritm table but i am checking the wait for condition in a different table thats why i am using the script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 07:33 AM
Thank you for helping us to understand.
please try the script suggested by @Brad Bowman , in addition you can initialise answer variable to false in the beginning of your script.
You may check below article to understand how "Wait for Condition" works.
For additional info and to know how "wait for condition" works check below article:
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 07:28 AM
Keep it simple:
var gr_vm = new GlideRecord('u_vm_automation_scheduler');
gr_vm.addQuery('u_requested_item',current.sys_id);
gr_vm.query();
if (gr_vm.next()) {
if (gr_vm.u_status == 'Success' || gr_vm.u_status == 'Error') {
answer = true;
}