Workflow Catalog Task condition(s)
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
| Workflow Editor is a legacy product to maintain existing workflows already in production. For new use cases and workflows, use ServiceNow Workflow Studio. Workflow Studio is a low-code alternative to Workflow Editor. |
|---|
Hi there,
Ever stumbled over the Catalog Task utility within Workflows, which only contains one condition: Always? Out-of-the-box, after performing the Catalog Task activity (directly or after the "Wait for completion") the single Always condition will be triggered. So no matter what the actual result of the Catalog Task activity is, there's just one condition...
How can we change this behavior when working with Workflows? Or even better, how can we change this behavior by default?
Out-of-the-box
To visualize what we are talking about when discussing the Catalog Task activity which contains only one condition:
Conditions
So can we add conditions? Like "Complete" and "Incomplete"? To be short: Yes, that's possible. One side note: checking on the actual result, can only be done when using "Wait for completion".
You can edit conditions through double-clicking on an existing condition. Adding a condition can be done through right-clicking on the activity, and adding a new condition.
Complete Condition
activity.result == 3
Incomplete Condition
activity.result == 4 || activity.result == 7
Permanent adjustment
In the step above, we changed the Conditions on a specific "Catalog Task" activity within one Workflow. Though, could we change this for all future use of the "Catalog Task" activities?
The Conditions which are applied upon drag & drop of a new "Catalog Task" activity onto your Workflow Canvas, are actually stored within the "Condition defaults" table [wf_condition_default].
When searching for the "Catalog Task" Activity definition, actually no results will be found! The reason is simple: there are no conditions set up, therefore automatically Always will be populated as a condition.
So let's set up our own conditions!
Complete
Incomplete
UI Policy
Like already mentioned, these conditions can only be applied when using the Catalog Task utility with "Wait for completion" checked. This checkbox is already checked by default out-of-the-box. To make sure this checkbox won't be manually changed, we'll set up a UI Policy and UI Policy Action to hide the "Wait for completion" field.
Result
When re-running a Workflow with the new Catalog Task activity with Complete and Incomplete conditions, the condition will match the actual results (State) of the Catalog Task. Complete when the state is Closed Complete (3), Incomplete when the state is Closed Incomplete (4) or Closed Closed Skipped (7).
The Catalog Task activity now looks by default like:
Share
An Update Set with these Condition adjustments can be downloaded from Share:
- Workflow Catalog Task conditions
---
And that's it actually. Hope you like it. If any questions or remarks, let me know!
Kind regards,
Mark Roethof
ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP
1x ServiceNow Community MVP
---
https://www.servicenow.com/community/developer-articles/workflow-catalog-task-condition-s/ta-p/2301055
