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 prerequisites. For their prerequisites, for example, the assigned roles and or preferences.

getAccessToken()


This Use this method returns to return an access token of the current user within the current session.

In the following cases, it It returns an empty string in the following cases:

  • calling this the method is called within any scheduled functionality (for example, Scheduled Script),a scheduled script).
  • the method is called calling this method by any other functionality without any direct user actions and collateral side request on the client - side requests.

Return:

TypeDescription
String

The method returns the current user access token. If it the user is not set, it returns an empty string is returned.

Example:

Code Block
languagejs
themeEclipse
titlegetAccessToken
linenumberstrue
const user = new SimpleUser();
ss.info(user.getAccessToken()); 
// Info: PV8wLSJWEJONyvF87aIQn2b--7EMEhy_

getContext()


This method allows getting Use this method to get the information about the current user given user in the context (whether this is 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 objectThis method returns an object containing that contains the current user information about the current user.

Example:

Code Block
languagejs
themeEclipse
titlegetContext
linenumberstrue
const user = new SimpleUser();
ss.info(user.getContext().username); 
// Info: admin

getID()


This Use this method gets to get the current user ID.

Return:

TypeDescription
String
Current
This method returns the current user ID.

Example:

Code Block
languagejs
themeEclipse
titlegetID
linenumberstrue
const user = new SimpleUser();
ss.info(user.getID()); 
// Info: 155931135900000099

getPreference(preferenceName)


This method allows getting a Use this method to get the value of the specified User Preference user preference for the current user.

Parameter(s):

NameTypeMandatoryDefault Valuevalue
preferenceNameStringYN

Return:

TypeDescription
StringThis method returns the specified preference value for the current user. If the specified preference does not exist, it returns
'
null
'
.

Example:

Code Block
languagejs
themeEclipse
titlegetPreference
linenumberstrue
const user = new SimpleUser();
ss.info(user.getPreference('application')); 
// Info: 155931135900000002

hasRole(role)


Use this method to find out whether check if the current user has a the specified role or the admin role. It  always 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):

NameTypeMandatoryDefault Valuevalue
roleStringYN

Return:

TypeDescription
Boolean

This method returns ' true ' if the user has a specified role or admin; otherwise, it returns 'false'.

Example:

Code Block
languagejs
themeEclipse
titlehasRole
linenumberstrue
const user = new SimpleUser();
ss.info(user.hasRole('service_owner')); 
// Info: false

setPreference(preferenceName, value)


Use this method to set a value for the user preference settings of the current user. 

The system creates a preference with the specified name This method allow setting a value for an existing or newly created User Preference for the current user, if such a preference does not exist.

Warning

The value parameter must be no longer than 255 symbols.

Parameter(s):

NameTypeMandatoryDefault Valuevalue
preferenceNameStringYN
valueStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titlesetPreference
linenumberstrue
const user = new SimpleUser();
user.setPreference('language', 'en');
ss.info(user.getPreference('language')); 
// Info: en


Table of Contents
absoluteUrltrue
classfixedPosition
printablefalse