[UNIQUE] - Test if a Value is Unique
The [UNIQUE]
function is used to test if a given value for an attribute already exists within eADM. It is very useful when creating aliases, email addresses, usernames, or similar attributes that must be unique.
If the value being tested already exists, the function automatically appends a sequential number (1, 2, 3, etc.) to the value to make it unique. For email addresses, the function includes an optional parameter to ensure this number is correctly placed before the "@" symbol and domain.
Syntax
[UNIQUE;SearchValue;Attribute;EmailDomain]
SearchValue: The value you want to check for uniqueness.
Attribute: The attribute field in eADM that you want to test the
SearchValue
against (e.g.,Email
).EmailDomain: An optional parameter used when generating email addresses. It ensures that any sequential number is added before the email domain, not at the end of the address.
Use case - Generating a Unique Email Address
The [UNIQUE]
function is often combined with other functions to first generate a value and then ensure it is unique. The following expression generates an email from a user's display name and then checks for uniqueness.
[UNIQUE;[LOWER;[REPLACE;[CLEAN;[displayname]]; ;.]]@utfjord.kommune.no;Email;@utfjord.kommune.no]
How it Works:
The inner functions (
CLEAN
,REPLACE
,LOWER
) format the user's fulldisplayname
into a standard email prefix, such as "anne.johansen".The
@utfjord.kommune.no
domain is appended to create a full email address.The
UNIQUE
function then checks if "anne.johansen@utfjord.kommune.no" already exists in theEmail
attribute in eADM.If the address is already in use, the expression will return a numbered version, such as "anne.johansen1@utfjord.kommune.no". If it is not in use, it will return the original "anne.johansen@utfjord.kommune.no".
Note: Expressions like this are commonly used in export templates, for example, when provisioning users to Active Directory (AD).