Trigger Namespace

The Trigger namespace provides the ability to get the name (or rather, type) of a trigger and time (date/timestamp) when it occurred. You can use this universal namespace for auditing purposes with both asset-related triggers and system-related triggers. See Using Appropriate Actions and Namespaces with Triggers for Expression Rules. Examples of names for triggers are Alarm, AlarmExtendedDataChange, InactiveAlarm, and so forth.

If the symbol provides a string to compare, that value is case-sensitive. For example, make sure the Trigger name value is written in the correct case for comparison to the related trigger type (If Trigger.name = "Alarm" Then ).

Symbols

The following table lists the qualified uses (you must always use the namespace) and data types for the symbols of the Trigger namespace; it also provides examples:

 

Qualified name

Returns

Example

Trigger.time

Long

Then: Audit("data-management", "User logged in at " + FormatDate(Trigger.time))

Trigger.name

String

Note: This symbol is case-sensitive.

Then: Audit("data-management", Trigger.name + " event at " + FormatDate(Trigger.time))

Example

The following example shows how you can use the Trigger namespace and its symbols in an expression rule:

 Trigger=UserLogin

 If (Trigger.name=="UserLogin" && User.name=="JSmith" && User.isfirstlogin)

 Then Audit("user-access", "New user logged in:" + User.name)

In this example, when the Platform receives a UserLogin message (the trigger type is used to indicate that a user logged in), it determines if the user's name is "JSmith" and if this login was the first login for JSmith. If all conditions are true, the Platform creates the following Audit message in the category user-access: "New user logged in: JSmith." If any of the conditions evaluate to false, nothing happens.