Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This server-side class allows to provides methods that get information about the current user and his 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:

TypeDescription
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
languagejs
themeEclipse
titlegetAccessToken
linenumberstrue
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 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
StringCurrent 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 Use this method allows to get a the value of the specified User Preference specified 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)


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):

NameTypeMandatoryDefault Valuevalue
roleStringYN

Return:

TypeDescription
Boolean

This method returns ' true ' if the user is granted with 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)


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):

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