Skip to content

Commit 14aea1d

Browse files
authored
Client Script to use Logged-in User Information (#1713)
* client script user info * client side user information
1 parent c16ce79 commit 14aea1d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The Glide User (g_user) is a global object available within the client side. It provides information about the logged-in user.
2+
3+
Property Description
4+
5+
g_user.userID Sys ID of the currently logged-in user
6+
g_user.name User's Full name
7+
g_user.firstName User's First name
8+
g_user.lastName User's Last name
9+
10+
# It also has some methods available within the client side.
11+
12+
Method Description
13+
14+
g_user.hasRole() Determine whether the logged-in user has a specific role
15+
g_user.hasRoleExactly() Do not consider the admin role while evaluating the method
16+
g_user.hasRoles() You can pass two or more roles in a single method
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if (g_user.hasRole('admin') || g_user.hasRole('itil')) {
2+
// User has at least one of the roles
3+
g_form.setDisplay('internal_notes', true);
4+
}
5+
6+
if (g_user.hasRole('admin') && g_user.hasRole('itil')) {
7+
// User must have both roles
8+
g_form.setDisplay('advanced_settings', true);
9+
}
10+
11+
//Using the parameters to set a field value
12+
g_form.setValue('short_description', g_user.firstName);
13+
14+
g_form.setValue('short_description', g_user.lastName);
15+
16+
g_form.setValue('short_description', g_user.name);
17+
18+
g_form.setValue('short_description', g_user.userID);

0 commit comments

Comments
 (0)