Case Conditionality
Last updated
Last updated
Enate offers lots of flexibility when it comes to adding conditionality to your Case flows to specify multiple optional flows of Actions which the Case could choose to execute, depending upon which condition is met.
You add a condition by clicking on the menu on the right-hand side of a step and selecting 'Condition'. This is also how you can edit an already existing condition.
In the following pop-up, add a name to be shown in the flow diagram, then select the field you want to be basing your condition on from the ‘Field’ dropdown.
You have multiple types of field that you can choose from:
Date and Time fields
Platform fields
Work Item fields
Custom Data fields
Once you have selected the desired field to base you condition on, you need to add a Branch Name, a condition and a Value.
Branch Name - this is the name that will appear in the Case flow for that branch
Condition - depending on the type of field you have chosen, you have the option of selecting 'Equals', 'Does Not Equal', 'Greater than', 'Less than', 'Greater than or equals to', 'Less than or equals to' and 'Between'.
Value - the value that the condition will be measured against. This is the value entered by a Work Manager user at runtime.
You can add as many branches to your condition as you need.
Alternatively, you can choose to add your condition in 'Advanced' mode - see below.
Click to 'Validate' your condition and then clock 'OK' to add it to your Case flow.
In the Case flow your condition will appear as a diamond and the different branches you have configured are listed below it.
You then need to add the Actions you want your Case to follow when one of the branches' conditions are met.
When you are building these Conditions, Enate is constructing them in C# scripting in the background. You can always easily define simple Conditions in the way described above, but if you want to expose that underlying scripting code to make some advanced adjustments, you can do this by selecting the ‘Advanced Mode’ icon in the Condition popup screen:
Doing so will expose the underlying Expression being created in the Condition and allow you to make adjustments and even write your Expressions from scratch.
This allows more advanced users with knowledge of C# to write complex Conditions involving standard C# functions such as Substring on a string or Day, DayOfWeek, DayOfYear on a Date, etc., exposing huge amounts flexibility to model your Conditions against any number of business scenarios.
Furthermore, the “value” of a branch can also be defined in C# script. For instance, it is possible to compare two Field values by entering the value as a field such as [workItemStartDate]. See below for an example.
Note: A regularly used Condition which is not currently accessible via the Simple view is: WorkItemHasFileWithTag("file tag name"). It is, however, available on Advanced mode. However, there are a number of important aspects to take into account when writing these expressions in C#, for example case sensitivity and awareness of .Net Datatype for each of the Enate Datatypes. Please see the Appendix for more detailed information.
Once you have written an expression in Advanced mode, you can validate it using the ‘Validate’ button. This will check your script for syntax errors. For example, an Expression of “[customerName].ToLowerInvarant()”, which has a typo in the ToLowerInvariant reference, would produce a validation error of:
Expression: (1,37): error CS1061: 'string' does not contain a definition for 'ToLowerInvarant' and no accessible extension method 'ToLowerInvarant' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
This error will also be accompanied by a link to the Microsoft help page related to your syntax error.
You can also test your Expression on the free dotNetFiddle website (https://dotnetfiddle.net/). Simply click the “Open dotNetFiddle demonstration” link on the Condition Popup and press the “copy” button to copy an executable (and commented) version of your expression and branches to the clipboard. Then in dotNetFiddle paste the script.
In dotNetFiddle you can change the test values to replicate different scenarios.
For example, for the following condition:
The following script is produced to test in .Net Fiddle:
When running the script you can see the output branch is “default” because the default test value for “customerName” is “This would be the Customer Name” which is not one of the outputs. You can change the test value in the variables block near the top of the script:
If we change the test value to “my first customer” then the script result is “Customer 1”, indicating that if used at runtime Enate would run the Actions under the Customer 1 branch.
Writing C# is beyond the scope of Enate Training, however some sample functions which may inspire you are:
Expression: [customerName].ToLowerInvariant()
Branch Values:“my first customer”
“my second customer”
Etc
Note: The value for the branches must also be in lower case. The use of the ToLowerInvariant() method is preferred over ToLower() as a C# best practice.
Expression: [customerName].DayOfWeek()
Branch Values:DayOfWeek.Monday
DayOfWeek.Tuesday
DayOfWeek.Wednesday
etc
Note: As per the documentation for the DayOfWeek property (https://docs.microsoft.com/en-us/dotnet/api/system.datetime.dayofweek) the result is value of type System.DayOfWeek (https://docs.microsoft.com/en-us/dotnet/api/system.dayofweek).
Expression: [workItemStartDate].AddDays(3)
Branch Values:[lastActionEndDate]
Note: The Condition of the branch should be set to “Less than”.
Expression: [workItemStartDate] .Date()
Branch Values:[lastActionEndDate].Date()
Note: The use of “.Date()” removes the Time component of the value; comparing only the date.