By combining the [REFERENCE] and [LASTVALUE] functions, you can retrieve historical attribute values. A common use case is to retrieve a user's previous manager and department details, which is useful for processes such as sending email notifications during a job change. This guide also covers using the[IFEMPTYUSE] function to provide a default value if historical data is not available.
Syntaxes
-
[LASTVALUE; Attribute]: Retrieves the most recent previous value of the specifiedAttribute. -
[REFERENCE; AttributeToReturn; LookupAttribute; LookupValue; MatchValue]: Looks up an object and returns a specified attribute from it. -
[IFEMPTYUSE; PrimaryValue; FallbackValue]: Returns thePrimaryValueif it is not empty; otherwise, it returns theFallbackValue.
Use Cases
Retrieving a Previous Manager's Contact Information
To find the email address or display name of a user's most recent former manager, you can use [LASTVALUE; Manager] as the value to look up.
-
To get the previous manager's email address:
[REFERENCE;Email;UserId;1;[LASTVALUE;Manager]]
-
To get the previous manager's name:
[REFERENCE;DisplayName;UserId;1;[LASTVALUE;Manager]]
Providing a Fallback to the Current Manager
If a previous manager is not found, the expressions above will return an empty value. To provide the current manager's details as a fallback, wrap the expression in an[IFEMPTYUSE] function.
-
Email (Fallback to Current Manager):
[IFEMPTYUSE;[REFERENCE;Email;UserId;1;[LASTVALUE;Manager]];[REFERENCE;Email;UserId;1;[manager]]] -
Name (Fallback to Current Manager):
[IFEMPTYUSE;[REFERENCE;DisplayName;UserId;1;[LASTVALUE;Manager]];[REFERENCE;DisplayName;UserId;1;[manager]]]
Advanced Usage: Non-Exact Matching
The [REFERENCE] The function has an optional final parameter that determines whether the lookup requires an exact match:
[REFERENCE;AttributeToReturn;LookupAttribute;LookupValue;MatchValue;IsExactMatch]
When the IsExactMatch the parameter is set to false, the MatchValue The field supports wildcards (%). This is useful for complex, position-specific lookups, such as when a manager is employed by multiple companies and may have more than one User ID.