If you want to be able to take action when a new user logs in or when a user in a particular user group logs in, you can use the UserLogin message to generate an expression rule. Similarly, you can take action when a particular user logs out (UserLogOut event). For example, you might want to enable a rule or send a notification. To enable a rule, use the EnableRule action. To send a notification, you need to use the PublishObject action. When the UserLogin or UserLogOut message occurs, the expression rule is evaluated and, if appropriate, executes the action.
Use this namespace with system-related triggers and NOT with asset-related triggers. See Using Appropriate Actions and Namespaces with Triggers for Expression Rules.
UserLogin and UserLogout are system messages, so you cannot use them in the context of an asset nor can you use them in conjunction with any asset-related namespace in an expression rule. The symbols for the User namespace provide access to information stored in the Platform about the user associated with the message:
o time - the time since the UserLogin or UserLogout event occurred; time is Unix epoch, in seconds since 1970.
o name - the login name of the user for whom the message occurred.
o fullname - the first and last names of the user who logged in or out.
o isadmin - True if the user who logged in or out is an Administrator; False if the user is a non-administrative user.
o phone - the telephone number of the user who logged in or out.
o fax - the telephone number of the facsimile machine for the user who logged in or out.
o email - a comma-separated list of the e-mail addresses of the user who logged in or out.
o usergroups - a comma-separated list of the user groups that the user belongs to.
o isfirstlogin - True if this is the first time that the user has logged in.
o lastlogintime - the last time the user logged in, in seconds since 1970, Unix Epoch time. On a Logout trigger, lastlogintime gives the session duration in seconds.
o total - the total number of users logged in at the time of the message.
When you use this namespace in an expression rule, it is recommended that you use the Qualified name (namespace plus symbol). However, because the expression rule is generated by the UserLogin or UserLogout message, use of the namespace is not required. The User namespace always refers to the user associated with the message.
The following table shows the qualified and unqualified names, the data type, and examples of ways you can use the symbols. Notice that the namespace always starts with a capital letter while the symbols always start with lowercase letters. If the symbol provides a string that will be used in comparisons, that value will be case-sensitive. For example, make sure the Trigger name value is written in the correct case for comparison (If Trigger.name = "Alarm" Then ).
Qualified name |
Unqualified |
Returns |
Example |
User.time |
time |
Long |
If (User.time==600) |
User.name |
name |
String Note: This symbol is case-sensitive. |
If (User.name=="tsmith") |
User.fullname |
fullname |
String Note: This symbol is case-sensitive. |
If (User.fullname=="Tom Smith") |
* User.isadmin |
isadmin |
Boolean |
If User.isadmin * |
User.phone |
phone |
String |
If (has("7283564414", User.phone)) |
User.fax |
fax |
String |
If (User.fax=="781 721 8282") |
User.email |
String Note: This symbol is case-sensitive. |
If (has(tsmith@axeda.com, User.email)) |
|
User.usergroups |
usergroups |
String Note: This symbol is case-sensitive. |
If (has("services", User.usergroups)) |
* User.isfirstlogin |
isfirstlogin |
Boolean |
If isfirstlogin * |
User.lastlogintime |
lastlogintime |
Long |
If (Date(User.lastlogintime) == Date("06/15/2010") |
User.total |
total |
Integer |
If (User.total > 50) |
* These symbols are Boolean. Do NOT use an operator and value. To test for a value of true, use the namespace and symbol (User.isadmin or User.isfirstlogin). To test for a value of false, use the NOT (!) operator with the namespace and symbol (!User.isadmin or !User.isfirstlogin). See also Creating IF comparisons with Boolean and non-Boolean values.