Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
This server-side class allows getting provides methods that get information about the current user and his or her their prerequisites, for example, the assigned roles and or preferences.
getAccessToken()
This method returns Use this method to return an access token of the current user within the current session.
In some cases it It returns an empty string . These in the following cases are:
- calling this the method is called within any scheduled functionality (for example, Scheduled Scripta scheduled script).
- calling this the method is called by any other functionality without any direct user actions and collateral side request on the client - side requests.
Return:
Type | Description |
---|---|
String | Method The method returns the current user current user access token. If it the user is not set, then it returns an empty string is returned. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const user = new SimpleUser();
ss.info(user.getAccessToken());
// Info: PV8wLSJWEJONyvF87aIQn2b--7EMEhy_ |
getContext()
This Use this method allows to get current user information given the context (whether this is the the information about the current user in the given context. For example, check if a system user or an employee having has additional attributes against compared to regular users).
Return:
Type | Description |
---|---|
SimpleRecord object | This method returns an object containing that contains the current user information about the current user. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const user = new SimpleUser(); ss.info(user.getContext().username); // Info: admin |
getID()
This Use this method gets to get the current user ID.
Return:
Type | Description |
---|---|
String | Current This method returns the current user ID. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const user = new SimpleUser(); ss.info(user.getID()); // Info: 155931135900000099 |
getPreference(preferenceName)
This Use this method allows to get a the value of the specified User Preference specified user preference for the current user.
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
preferenceName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns the specified preference value for the current user. If the specified preference does not exist, it returns 'null'. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const user = new SimpleUser(); ss.info(user.getPreference('application')); // Info: 155931135900000002 |
hasRole(role)
This Use this method allows to find out whether check if the current user is granted with a has the specified role or notthe admin role. It always returns true if always returns true if the current user has the admin role.has the admin role. When checking a role that has the Elevate privileges checkbox selected, the method returns false if the user with the admin role has not elevated to the specified one.
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
role | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns ' true ' if the user is granted with has a specified role or admin; otherwise, it returns 'false'. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const user = new SimpleUser(); ss.info(user.hasRole('service_owner')); // Info: false |
setPreference(preferenceName, value)
This Use this method allow to set a value for an existing or newly created User Preference the user preference settings of the current user.
The system creates a preference with the specified name for the current user, if such a preference does not exist.
Warning |
---|
The value parameter must be no longer than 255 symbols. |
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
preferenceName | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const user = new SimpleUser(); user.setPreference('language', 'en'); ss.info(user.getPreference('language')); // Info: en |
Table of Contents | ||||||
---|---|---|---|---|---|---|
|