@UserName (Formula Language)
Returns the current user name.
If the user name is hierarchical, @UserName returns it in canonical format (including the CN, OU, O, and C identifiers). To return the name in abbreviated format (omitting those identifiers), use @V3UserName.
Notes®
- If you used @UserName in Release 3, it is automatically converted to @V3UserName in Release 4 or later to preserve the functionality of your formulas. If you change those formulas to use @UserName, be sure to recompile them under Release 4 or later. If you use @UserName in Release 4 or later, a database created in Release 3 will not recognize the formula until you upgrade that database. If the formula will be evaluated in Release 3, use @V3UserName.
- With Release 5, @UserName returns the alternate name as well as the primary name which is associated with the ID.
Syntax
@UserName ( index )
Parameters
index
Number. Optional. Indicating the index of user names. 0 is for primary name and 1 is for the alternate name. If this parameter is omitted, @UserName returns the primary name.
Return value
name
Text. The primary or alternate user name.
Usage
When a formula runs on a server, the agent signer is considered the current user. Therefore, @UserName should only be used on local databases, where it will return the user's name. Using @UserName in server-based private views also returns the user's name, but produces unpredictable results if the views on the server are rebuilt using Updall. You should not use @UserName in a public view, doing so produces unpredictable results. Also, if the field that you are referencing changes, you will get unpredictable results because the index has to be rebuilt to accommodate the new information.
One use for @UserName is to display only those documents relevant to the current user. For example, your Service Request database could use @UserName in the private view named Assignments to display each technician's assignments, weeding out everyone else's:
SELECT @UserName=AssignedTo
However, the user can still design a different private view that retrieves all documents, so don't depend on @UserName as a security mechanism.
For an alternative way to display only documents relevant to the current user, see "To show a single category in an embedded view."
If you are using Release 5 and have an alternate name as well as a primary name, it is best to store the alternate name in the document as author information when using the extended feature of @UserName.
Examples
- This example returns CN=Robert T. Katsushima/OU=JPN/O=Acme if
this is the name associated with the current user ID.
@UserName(0)
- This example returns Robert T. Katsushima.
@Name([CN];@UserName)
- This example returns CN=Rob Katsushima/OU=JPN/P=Acme if this is
the first alternate name associated with the current user ID.
@UserName(1)
- This example returns Fletcher if William Fletcher is the name
associated with the current User ID.
@Right(@UserName;" ")
- This example returns FLETCHER if William Fletcher is the name
associated with the current User ID.
@UpperCase(@Right(@UserName;" "))
If the user id is a hierarchical id, the following code returns FLETCHER:
@UpperCase(@Right(@Name([CN]; @UserName); " "))
- This example returns the name in canonical format as shown. Given
this hierarchical user ID: CN=Mary Tsen/OU=Illustration/OU=Documentation/OU=Development/OU=R&D/O=WorkSavers/C=US.
To return the name in abbreviated format (omitting the CN, OU, O,
and C identifiers), use @V3UserName.
@UserName