sfGetCurrentUser
Returns the properties of the user who is currently logged in.
Syntax
sfGetCurrentUser (propertyName)
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
propertyName | string | no | Property (attribute) of the user. If no propertyName is mentioned, the UserName of the user is returned. |
User properties
The function refers to a User object. Some of the user properties are available to access using the function.
Standard properties
PropertyName | Description |
---|---|
Id | User Id (36-characters long unique identifier of a user) |
DisplayName | Full name as displayed on screen |
Initials | Initials |
FirstName | First name (Given name) |
MiddleName | Middle name |
LastName | Last name (Family name) |
UserName | Username (for Smartflow applications) |
Locale | Locale code of the default language configured |
Roles
A user can be assigned one or more roles. The roles assigned to a user can be obtained using “Roles” property. It returns a comma separated string of the roles assigned to the user.
For example,
Default, Administrator, Supervisor
Usergroup
A user is associated with a usergroup. It can be obtained using “UserGroup” property. It returns the usergroup as a string.
For example,
Normal
Custom properties
If a user has been assigned custom properties, they can also be obtained by passing the custom property name as parameter.
Usage examples
Example 1
The current user identifier be obtained using,
sfGetCurrentUser ('Id')
Returns the unique identifier of the logged in user. e.g. 919AE23D-A055-4A89-BD93-D0A96BEF68A1
Example 2
The full name of the current user can be obtained using,
sfGetCurrentUser('DisplayName')
Returns the full name of the user as displayed on screen. e.g. John Smith.
Example 3
The username of the logged in user can be obtained using,
sfGetCurrentUser('UserName')
Returns the username of the logged in user. e.g. john.smith or john.smith@example.com.
The username can also be obtained by not specifying the property name, in which case, the username is returned by default.
Example 4
To obtain the list of roles the current user has been assigned,
Returns a comma separated string of the roles assigned to the user. e.g. Default, Administrator, Supervisor
Example 5
Let us assume that the users in a domain have an additional property (custom property) named CompanyNumber. The company number of the current user can be obtained using,