This class provides access to the methods returning information about the current user and his user's prerequisites. The SimpleUser API class usage is getting rid of using slower SimpleRecord queries for user information retrieving,Using the SimpleUser API allows you to access the user information quicker than using SimpleRecord queries.
s_user.accessToken
Returns This method returns access token of the current user.
Return:
Type | Description |
---|
String | Access token of the current user. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_user.accessToken |
---|
linenumbers | true |
---|
|
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
Returns Using this method, you can retrieve the first name of the current user.
Return:
Type | Description |
---|
String | First name of the current user. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_user.firstName |
---|
linenumbers | true |
---|
|
console.log(s_user.firstName);
//John |
s_user.getFullName()
Returns the Using this method, you can retrieve full name (first and last name names) of the current user (see the values of the fields "First name" and "Last Name").
Return:
Type | Description |
---|
String | First and last name of the current user. |
Code Block |
---|
language | js |
---|
title | s_user.getFullName() |
---|
linenumbers | true |
---|
|
const commentValue = `${s_user.getFullName()}: "${s_form.getValue('comment')}"`;
s_form.setValue('additional_comment', commentValue); |
s_user.lastName
Returns the first Using this method, you can retrieve the last name of the current user.
Return:
Type | Description |
---|
String | Last name of the current user. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_user.lastName |
---|
linenumbers | true |
---|
|
console.log(s_user.lastName);
//Doe |
s_user.userID
Returns Using this method, you can retrieve the user ID of the current user.
Return:
Type | Description |
---|
String | The sys_id value for the current user. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_user.userID |
---|
linenumbers | true |
---|
|
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.
Type | Description |
---|
SimpleRecord object | Object containing user information |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | 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
Returns Using this method, you can retrieve the username of the current user 's username (for example, helpdesk.agent).
Please Take a note that it does not return user's name, whether it be first name, or last name. , or full name (for example, John, or Doe, or John Doe).
Type | Description |
---|
String | ID of the current user. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_user.userName |
---|
linenumbers | true |
---|
|
console.log(s_user.userName);
//"admin" |