Rules Examples

Table of Contents

Check whether a text-field contains a value

The following expression checks whether the Firstname-field contains a value.

=Data("Firstname").IsNotEmpty

Check whether the birth-year is greater than 1970

The following expression checks whether the Birth-year of an employee is greater than 1970 using the functions of the System.DateTime .NET type.

=Data("BirthDate").DateTime.Year > 1970

Check whether a numeric value is within a specific range

The following expression checks whether the VacationDays field is within a range of at least 0 and at maximum 50 days.

=Data("VacationDays").Integer >= 0 && Data("VacationDays").Integer <= 50

Check whether a numeric value exceeds a specific level

The following expression checks whether the VacationDays-field exceeds 100.

=Data("VacationDays").Integer > 100

Check whether a text-field contains a valid value (Expression-Syntax)

The following expression checks whether the Gender-field only contains the values “M” or “F”.

=Data("Gender").String == "M" || Data("Gender").String == "F"

Check whether a text-field contains a valid value (Script-Syntax)

This script does the same as the previous expression. It checks whether the Gender-field only contains the values “M” or “F”. But this time it uses the script-language what allows to split the code into smaller pieces. This makes the code more easier and understandable.

var gender = Data("Gender").String;
var allowedValues = new List() { "M", "F" };
return allowedValues.Contains(gender);

Complex validation logic

The following script calculates the age of an employee using the Birthdate-field. It then checks whether the employee has got the right amount of Vacation-days depending on the age.

var age = DateTime.Today.Year - Data("BirthDate").DateTime.Year;
var actualVacationDays = (double)Data("VacationHours").Decimal / 8.5;
var availableVacationDays = 0;
if (age >= 25) {
  availableVacationDays = 25;
}
else {
  availableVacationDays = 20;
}
return actualVacationDays == availableVacationDays;