From 4487cedea268b8389948fc45d72ce9836822f4e5 Mon Sep 17 00:00:00 2001 From: kmxo Date: Thu, 2 Oct 2025 20:01:35 -0300 Subject: [PATCH 1/2] client script user info --- .../Get Logged in User Information/README.md | 16 ++++++++++++++++ .../Get Logged in User Information/script.js | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Get Logged in User Information/README.md create mode 100644 Client-Side Components/Client Scripts/Get Logged in User Information/script.js diff --git a/Client-Side Components/Client Scripts/Get Logged in User Information/README.md b/Client-Side Components/Client Scripts/Get Logged in User Information/README.md new file mode 100644 index 0000000000..f848585793 --- /dev/null +++ b/Client-Side Components/Client Scripts/Get Logged in User Information/README.md @@ -0,0 +1,16 @@ +# The Glide User (g_user) is a global object available within the client side. It provides information about the logged-in user. + +Property Description + +g_user.userID Sys ID of the currently logged-in user +g_user.name User's Full name +g_user.firstName User's First name +g_user.lastName User's Last name + +# It also has some methods available within the client side. + +Method Description + +g_user.hasRole() Determine whether the logged-in user has a specific role +g_user.hasRoleExactly() Do not consider the admin role while evaluating the method +g_user.hasRoles() You can pass two or more roles in a single method diff --git a/Client-Side Components/Client Scripts/Get Logged in User Information/script.js b/Client-Side Components/Client Scripts/Get Logged in User Information/script.js new file mode 100644 index 0000000000..1eb62c5b35 --- /dev/null +++ b/Client-Side Components/Client Scripts/Get Logged in User Information/script.js @@ -0,0 +1,18 @@ +if (g_user.hasRole('admin') || g_user.hasRole('itil')) { + // User has at least one of the roles + g_form.setDisplay('internal_notes', true); +} + +if (g_user.hasRole('admin') && g_user.hasRole('itil')) { + // User must have both roles + g_form.setDisplay('advanced_settings', true); +} + +//Using the parameters to set a field value +g_form.setValue('short_description', g_user.firstName); + +g_form.setValue('short_description', g_user.lastName); + +g_form.setValue('short_description', g_user.name); + +g_form.setValue('short_description', g_user.userID; From 71bdfce028eb54a216b6cb21c9beaad88e7bf54d Mon Sep 17 00:00:00 2001 From: kmxo Date: Thu, 2 Oct 2025 20:24:57 -0300 Subject: [PATCH 2/2] client side user information --- .../Client Scripts/Get Logged in User Information/README.md | 2 +- .../Client Scripts/Get Logged in User Information/script.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Client-Side Components/Client Scripts/Get Logged in User Information/README.md b/Client-Side Components/Client Scripts/Get Logged in User Information/README.md index f848585793..79c5c88b9b 100644 --- a/Client-Side Components/Client Scripts/Get Logged in User Information/README.md +++ b/Client-Side Components/Client Scripts/Get Logged in User Information/README.md @@ -1,4 +1,4 @@ -# The Glide User (g_user) is a global object available within the client side. It provides information about the logged-in user. +# The Glide User (g_user) is a global object available within the client side. It provides information about the logged-in user. Property Description diff --git a/Client-Side Components/Client Scripts/Get Logged in User Information/script.js b/Client-Side Components/Client Scripts/Get Logged in User Information/script.js index 1eb62c5b35..2c35485db6 100644 --- a/Client-Side Components/Client Scripts/Get Logged in User Information/script.js +++ b/Client-Side Components/Client Scripts/Get Logged in User Information/script.js @@ -15,4 +15,4 @@ g_form.setValue('short_description', g_user.lastName); g_form.setValue('short_description', g_user.name); -g_form.setValue('short_description', g_user.userID; +g_form.setValue('short_description', g_user.userID);