Wait For Condition on catalog variable in Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 07:42 AM
I have a Wait For Condition flow action that I want to wait until a checkbox variable is checked on the RITM. I am using a script to achieve this, but its not working.
its throwing this error:
Wait For Condition script:
var checkbox = fd_data.trigger.request_item.variables.send_confirmation_email;
if(checkbox == "true"){
return true;
}
else{
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 09:24 AM
The Wait for Condition action in Flow Designer works differently than how you are used to coding a wait for condition script from the workflow editor. The Condition script in Flow Designer is expecting the script to evaluate to an encoded query string instead of returning true or false.
You should be returning a string such as "active=true^short_descriptionSTARTSWITHtest" from the script. It looks like the activity sets up a record watcher to check this condition against the record when it evaluates the action.
ServiceNow recommends you to only use the wait for condition for evaluating fields present on the table/record you are adding the wait for condition to. That means that you should avoid dot walking to reference fields, and waiting on catalog variables is not supported.
Now, you may be able to try to query for the catalog item variable itself and use that as the record you watching in the Wait for Condition. I haven't tried this myself, so results may vary. Personally, I see this as an oversight on ServiceNow's part if they are trying to replace Workflows with Flows. You have to do way too much additional work just for a simple condition.
I would like to hear someone's take from ServiceNow about this particular issue especially for catalog work. It is incredibly invaluable to be able to wait for a variable to change to a specific value before moving forward with the flow or to wait for a date specified in a variable. A wait for duration isn't the best option here as variable values can and will change and there may be additional conditions that need to be met. What I see happening is customers will start polluting the sc_req_item table with custom fields for their catalog items just so they can get the Wait for Condition to work for their requirements.
See this documentation for more details.