It is possible to define certain conditions for showing, hiding, or changing the text or a property in a notification message. For example, it is possible to use conditions to make sure that the client’s first name should be mentioned in the letter or – if the first name is not available – the client’s initials.
A condition consists of:
- An element or property
- An operator, like == < > != && || ()
- A value or property which needs to apply
- A linked action when one of the conditions is/is not met. Multiple actions can exist, each with their own conditions.
A condition is written with the Razor html syntax, and always has the default format: @(element operator value or property action when condition is valid action when condition is not valid)
Example: title based on gender
@(@Model.Client.Gender == “Male” ? “sir” : @Model.Client.Gender == “Female” ? “madam” : String.Empty)
This piece of text defines that when the client is a male, he should be addressed with ‘sir’. When it concerns a female client, she should be addressed with ‘madam’. When the gender is unknown, no title should be used. The condition then gives an empty result.
Conditions
Equal to
For example: The client is a female:
@Model.Client.Gender == “Female”
Not equal to
For example: The name of the location where the appointment takes place is not equal to “Medical Center”:
@Model.Location.Name != “Medical Center”
Smaller than
For example: The appointment is before 24th of December, 2016:
Attention! For the smaller than operator, the condition needs to be placed between brackets ( ).
(@Model.Appointment.StartDate < DateTime.Parse(“2016-12-24”))
Smaller than or equal to
For example: The client died before the start date of the appointment:
@Model.Client.DOD <= @Model.Appointment.StartDate
Larger than
For example: The start time of the appointment is later dan 06:00 PM:
@Model.Appointment.StartTime > TimeSpan.Parse(“6:00 pm”)
Larger than or equal to
For example: The start date of the appointment is on the 30th of November, 2016, or later:
@Model.Appointment.StartDate >= DateTime.Parse(“2016-11-30”)
Multiple conditions – AND logic: &&
For example: The state of the appointment is equal to “Failed” and the client has died:
@Model.Appointment.Status == “Failed” && @Model.Client.DOD <= @Model.Appointment.StartDate
Multiple conditions – OR logic: ||
For example: The appointment comes from external source “Backoffice X” or “Backoffice Y”:
@Model.ServiceContract.ExternalSource == “Backoffice X” || @Model.ServiceContract.ExternalSource == “Backoffice Y”
Multiple conditions – AND and OR logic combined: ( )
For example: The appointment comes from external source “Backoffice X” or “Backoffice Y”, and the client has died before the start date of the appointment:
(@Model.ServiceContract.ExternalSource == “Backoffice X” || @Model.ServiceContract.ExternalSource == “Backoffice Y”) && @Model.Client.DOD <= @Model.Appointment.StartDate
Linked actions
After stating the condition, the linked action (what needs to happen when the condition is met or not met) is defined:
- When the condition is met, the linked action is what comes after the ?
- When the condition is not met, then the text behind the : applies. It is possible to include a condition here, too, like:
- String.Empty: Leave empty. No text will be shown in the resulting message.
- “Text”: The text that is defined here will be shown in the resulting message.
Example
When the first name of the client is available, the first name will be displayed. If the first name is not available, the initials of the client will be shown:
@(@Model.Client.FirstName != null ? @Model.Client.FirstName : @Model.Client.Initials)
Special situations
No employee planned yet
It is possible that an employee has not yet been planned for an appointment. For example, no employee has yet been planned at the session on which the appointment was planned, or no one has been placed above the route yet on a classic planning board. In that case, an extra condition must be added to make sure this deficiency won’t cause any errors in the template.
Example:
In case no employee is known for the appointment yet, show the text ‘Employee not yet known’ where normally the last name of the employee would be shown:
@(@Model.Employee != null ? @Model.Employee.LastName : “Employee not yet known”)
No location planned
A location can also be a missing object at an appointment, for example at appointments that were planned on the day- or week planning board in classic.
Example:
In case no location is known for the appointment, show the text ‘No location linked’ or ‘Home location’ where normally the name of the location would be shown:
@(@Model.Location != null ? @Model.Location.Name : “Home location”)

