Develop > Expression Language > Expression Language for notifications

Expression Language for notifications

Expression Language can also be used in notifications with a slightly different syntax.

Expression Language syntax for notifications

The notification expression template format is: ${paramName:defaultValue} where at least one of the values, paramName or defaultValue, must be entered (you can enter one or the other or both).

  • paramName. A parameter of the current notification template. It returns the value stored in that parameter.
  • defaultValue. A phrase using Expression Language functions.

The notification includes whichever one of the above values is entered. If both values are entered, the paramName value is used if it exists for the current notification template. If it does not exist, the defaultValue value is used.

In summary, the following options are available:

  • paramName only. For example ${lastComment} means that the notification event contains the value in the parameter lastComment. (Note: no colon is required in this case.) If no such parameter exists for the notification template, it returns an empty string.
  • defaultValue only. For example, ${:entity.Id} means that the notification event contains the Id property of the current record. (Note: a colon is required before the expression.)
  • paramName and defaultValue. For example ${subject:concat('Hello', current_recipient.Name)}.

    • If the notification has a parameter called subject, then the notification event contains the value stored in that parameter.
    • If the notification has no parameter called subject, then the notification event contains the value returned by the expression ${concat('Hello', current_recipient.Name)}.

For task and approval records, the phrase ${:entity.parentEntity} returns the parent record of the task or approval. For example, for a notification on a task defined for a change record, the parent record is the change record.

Notification examples

The following expressions are relevant for notifications:

  • ${:current_user.Name}. Returns the current user name.

  • ${:entity.Type} ${:entity.Id}: ${:entity.DisplayLabel}. Returns the type, id and label of the record (3 expressions).

  • ${:entity.Type} ${:entity.Id}: ${sltName} 'is' ${percentBreached} 'breached'. Returns a string consisting of the record type and ID with two input parameters: sltname and percentBreached. These parameters are available for the user to input as constants or as expressions in the template business rule editor. The output notifies the user that the sltname parameter of the current record is percentBreached breached.

  • For task and approval records, the phrase ${:entity.parentEntity.PhaseId} returns the current phase of the parent record of the task or approval.

    Caution When constructing an expression using the parentEntity property in notifications, the properties following parentEntity must be valid properties of the parent record type.

Related topics