I've heard quite a few people say condition on action doesn't work sometimes (shown below). If you observe that issue, that may come from the same reason. In this post, I am sharing why that problem occurs, and how to resolve it.
Let me start with a working scenario. Place an "Item" property on screen. If user enters "CPU" and clicks "Check inventory and submit" button, system pops up a modal dialog saying "CPU is out of stock". If user enters some other Strings and does the same, the assignment gets submitted without popping up a modal dialog.
(1) If user enters "CPU" and clicks "Check inventory and submit"..
(2) System pops up a modal dialog as below.
(3) Instead, if user enters some other Strings and clicks "Check inventory and submit"..
(4) The assignment is finished and the case is routed to the next step.
Add two actions for the button click event - "Local action" and "Finish Assignment". Configure conditions for each action accordingly so that local action is run when Item is "CPU", while finish assignment is run when Item is not "CPU".
Not working scenario
Now, here is when things don't work as expected. Instead of having "Item" property on UI, remove it and set it by an activity. In a real world, this could be REST API to get inventory status from external system, but in this sample I am hardcoding it for the sake of simplicity.
(1) Remove an "Item" property from screen.
(2) Add "Refresh this section" action and fire an activity to populate "CPU" to Item property. This action has to be placed prior to both of two actions.
(3) You may expect the modal dialog to pop up just like the 1st scenario, but it does not work the same way. The assignment is completed and the case is routed to the next step. Note the "CPU" is loaded on the clipboard correctly.
Why these two scenarios behave differently? It is because "data-changed" meta data on the control can get updated only if the DOM (Document Object Model) is refreshed, and cannot get updated correctly in the middle of the execution of an action set. "data-changed" meta data can be observed if you turn on Developer tool as below.
Place the "Item" property on screen so that it is available in DOM at run time. This way, when the 1st action (Refresh this section) is performed and property is changed by activity, DOM gets re-generated and hence condition can work properly.
Also, most of the times the property shouldn't be visible for users. In that case, you can use "Hidden text" control shown below so the property won't take up unnecessary extra space.
***Edited by Moderator Marissa to update Platform Capability tags****