Introducing Custom Function-based Rule Properties
Rule properties are used in a number of places throughout the Dovetail suite, including:
- Business Rule Conditions
- Business Rule Action Messages
- Canned Response Variables
- Task Manager Properties
- Email Log Templates
Traditionally, a rule property would traverse a path through the schema, starting from the base object, and ending at a column.
For example, the Contact First Name property for a case would use the path case_reporter2contact:first_name.
However, there are instances where a path cannot be traversed, or where a calculation needs to be made.
For example, you may wish to fire a business rule only if all of the subcases on a case have been closed.
So your two business rule conditions would be:
- Number of Subcases is greater than zero
- Number of Open Subcases is equal to zero
Or, you may wish to fire a business rule if the Number of cases for product X within the last 7 days is greater than 10.
With these examples, there is not a schema path that can be traversed to provide these values.
Data from Other Systems
Or you may wish to use a variable (rule property) as part of a canned response that retrieves data from another system using a web service call.
Again, there is not a schema path that can be traversed to provide this data (since it comes from another system).
Plug in your own code
You can now write your own custom code for these rule properties. This opens up a whole new avenue for customization.
Dovetail provides an example code project that demonstrates custom function-based rule properties.
This project is freely available at https://dovetailsoftware.github.io/property-extensions/
That link provides more details, working code examples, and steps on how to build and deploy.
The examples include:
- Current Date
- Current Date & Time
- Number of Subcases
- Number of Open Subcases
- Number of Child Cases
- Number of Child Cases
- Number of Open Child Cases
- Apple Stock Price – This is an example of calling a web service
Create the Rule Property
Once your code has been written, and the assembly copied into the application directory, then the property can be defined using the Rule Property UI within Dovetail Agent (Agent version 14 or higher).
- Assign it a property name, as normal.
- Check the “Is Function” checkbox
- For the Path, rather than a schema path, type in the Class Name of your custom property function, such as NumberOfSubcases
Dovetail Agent – Canned Responses
Once you’ve built your custom assembly, simply drop that DLL into the Dovetail Agent/bin directory and restart the app.
First we set up the canned response. From an end user’s standpoint, these are just properties like all the others.
and when I use that canned response, they get resolved.
For example, when I log a note on a case, and select that canned response, I can see that the properties get resolved:
Once you’ve built your custom assembly, simply drop that DLL into the Rulemanager directory and restart Rulemanager.
You’ll then be able to use these custom function-based rule properties as:
- Business Rule Conditions
- Within Business Rule Action Messages
- Email Templates (such as the send_email_about_obj template)
Business Rule Condition
Here we can see the Number of Subcases property used in a business rule condition:
Business Rule Message
Here’s an email that was received due to a business rule message:
I can edit my email template (the send_email_about_obj template), and add the following to it:
The current Stock Price is [Apple Stock Price]
So now, whenever an email goes out, that rule property will get evaluated, and the email will contain that data:
Note: the context here is an email log, not a case. So be sure the Object Type for your rule property is Email Log, as shown here:
Once you’ve built your custom assembly, simply drop that DLL into the Carrier Service directory and restart Carrier.
These rule properties can be used within Carrier’s Task Manager extension.
You can use these custom function-based rule properties within Task Manager.
For example, I can setup a task that creates a subcase, and use these properties.
In this example, I’m using the [Apple Stock Price] property:
so that when the subcase is created, the notes show the Apple stock price:
What if I don’t use Dovetail Agent?
As I mentioned earlier, the property can be defined using the Rule Property UI within Dovetail Agent (Agent version 14 or higher).
But if you’re not using Dovetail Agent, but you are using Dovetail Rulemanager, you can still take advantage of these.
Rule properties are stored in table_prop_name. There is a new custom field named x_is_function that defines this property as a function. If set to 1, this property will be evaluated as a function. If set to 0 (default), it will not be.
So you can simply create your rule property as normal, then you just need to set the x_is_function column to 1 for that property.
You can do this using a DAT file, using SQL, or using Dovetail Admin (version 3.7 or higher).
This functionality is available in:
- Dovetail Rulemanager version 2.2
- Dovetail Carrier version 2.3
- Dovetail Admin version 3.7
- Dovetail Agent version 14
You’ll also need the Custom Property Extensions Solution.
Now that you can write your own custom code for these rule properties, this opens up a whole new avenue for customization.
We already have one customer that is starting to use these, as they need to retrieve some data that resides in another system, and use that as a business rule condition.
I’m looking forward to seeing what other ideas our customers come up with to take advantage of this.
Sign up to get information like this delivered right to your inbox.