You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

This class provides methods returning information about the current user and user's prerequisites. Using the SimpleUser API allows you to access the user information quicker than using SimpleRecord queries.

s_user.accessToken


This method returns access token of the current user.


Return:

TypeDescription
StringAccess token of the current user.
s_user.accessToken
const url = new URL(`${API_BASE_URL}/export/json/${s_list.getTablesName()[0]}`);
url.searchParams.set('access-token', s_user.accessToken);
url.searchParams.set('condition', s_list.getQuery());
window.open(url, "_blank");


s_user.firstName


Using this method, you can retrieve the first name of the current user.


Return:

TypeDescription
StringFirst name of the current user.


s_user.firstName
console.log(s_user.firstName);
//John


s_user.getFullName()


Using this method, you can retrieve full name (first and last names) of the current user (see the values of the fields "First name" and "Last Name").


Return:

TypeDescription
StringFirst and last name of the current user.
s_user.getFullName()
const commentValue = `${s_user.getFullName()}: "${s_form.getValue('comment')}"`;
s_form.setValue('additional_comment', commentValue);

s_user.lastName


Using this method, you can retrieve the last name of the current user.


Return:

TypeDescription
StringLast name of the current user.


s_user.lastName
console.log(s_user.lastName);
//Doe


s_user.userID


Using this method, you can retrieve the user ID of the current user.


Return:

TypeDescription
StringThe sys_id value for the current user.


s_user.userID
const currentCaller = new SimpleRecord(s_user.user.essence);
currentCaller.get(s_user.userID, ()=> {
  s_form.setValue('email', currentCaller.email);
});

s_user.user


Returns a SimpleRecord object containing user data, such as first name, last name, sys_id value, and so on, formatted as JSON.


Return:

TypeDescription
SimpleRecord objectObject containing user information


s_user.user
console.log(JSON.stringify(s_user.user, null, 2));
/*"{
  "sys_id": "155931135900000001",
  "first_name": "Admin",
  "last_name": "Admin",
  "username": "admin",
  "essence": "user",
  "timezone": "Europe/Moscow",
  "language": "en",
  "photo_path": null,
  "elevate_access": -1,
  "version": "1.3.6",
  "dictionary": {...},
  "impersonate_state": null
}"*/

s_user.userName


Using this method, you can retrieve the Login (username) of the current user (for example, helpdesk.agent).


Return:

TypeDescription
StringUsername of the current user.
s_user.userName
console.log(s_user.userName);
//"admin"

  • No labels