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 ).
name - name (for example, type) of the trigger that is executing (returns a String). Examples include AlarmSeverityChange, InactiveAlarm, Registration, UserLogin, etc.
time - time that the trigger occurred, presented using the local time of the Axeda Platform. Note that this symbol returns the number of seconds since 1970 as the time, enabling you to subtract the current time at the Platform (Now() function) from the time the trigger occurred to determine the when the trigger occurred (returns a Long).
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)) |
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.