Functions are used to extend the capabilities of expressions. These are useful for performing a number of common calculations which frequently appear in rules.
There are many different types of functions that you can use in your rules:
Function Type | Use |
---|---|
Numerical functions | Used with number and currency variables to perform basic and complex arithmetic calculations, trigonometric calculations and maximum/minimum calculations |
Used with date variables to express the current date (based on the system date at the start of the session), to calculate a relative date, to find a date in a year, to get particular dates/days/months/years, to count periods between two dates, and to get an earliest/latest date | |
Time of day functions | Used with time of day variables to express the current time of day, to set the time of day, to calculate the difference in seconds/minutes/hours between two times of day, to extract the second/minute/hour from a time of day, and to get an earliest/latest time of day |
Date and time functions | Used with date and time variables to express the current date and time (based on the system date/time at the start of the session), to set the date and time, to calculate the difference in units between two dates, to extract a unit from a date and time, to extract a time of day, and to get an earliest/latest date and time |
Text functions | Used with text variables to combine text strings and to extract parts of text strings |
Entity and relationship functions | Used to perform operations on entity-specific data to produce global results, such as counting the number of instances of an entity, obtaining the highest/most recent or lowest/least recent value of an entity-level variable, and adding up numerical values gathered from each instance of the entity |
Temporal reasoning functions | Used in rules to compute results for, and express relationships that involve, attributes over multiple periods |
NOTE: If you have a project which uses a RLS (Rapid Language Support) parser, the syntax for the functions are defined in the configuration for that particular RLS parser. For more information on using an RLS parser, and changing the templates for the functions in such a project, see the Help available in the Rapid Language Support Tool.
Functions can be nested within other functions to form complex expressions.
To retrieve a minimum value from a given set of numbers (ie more than two), you can nest the Minimum function multiple times to accommodate your set of numbers. For example:
NOTE: If your set of numbers are instances in an entity, then use InstanceMinimum or InstanceMinimumIf entity functions.
To write a rule where a money value is always rounded up the nearest dollar, you would use nested functions as follows:
the total benefit paid in whole dollars = (((the total benefit paid truncated to 2 decimal places)+ 0.99) truncated to 0 decimal places)
The rounding up in this rule is achieved by:
If the total benefit paid is 180.7569 (as a result of previous calculations in the rulebase), then the first step truncates this 180.75. The second step adds 0.99 to 180.75 giving a figure of 181.74. The third step truncates this to 181.
See also: