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..79c5c88b9b --- /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..2c35485db6 --- /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);