<h2>GlideUser - getClientData(String key)</h2><br/><div style="overflow-x:auto"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta content="text/html; charset=UTF-8" /><meta name="copyright" content="(C) Copyright 2025" /><meta name="DC.rights.owner" content="(C) Copyright 2025" /><meta name="generator" content="DITA-OT" /><meta name="DC.type" content="concept" /><meta name="DC.title" content="GlideUser - Client" /><meta name="abstract" content="The GlideUser API provides methods that access information about the current user and current user roles. Using this API avoids the need to use the slower GlideRecord queries to get user information." /><meta name="description" content="The GlideUser API provides methods that access information about the current user and current user roles. Using this API avoids the need to use the slower GlideRecord queries to get user information." /><meta name="DC.subject" content="GlideUser, firstName, getClientData(string key), getFullName(), hasRole(String role, Boolean includeDefaults), hasRoleExactly(String role, Boolean includeDefaults), hasRoleFromList(String roles, Boolean includeDefaults), hasRoles(Boolean includeDefaults), lastName, GlideUser (client), setClientData(), userName, userID" /><meta name="keywords" content="GlideUser, firstName, getClientData(string key), getFullName(), hasRole(String role, Boolean includeDefaults), hasRoleExactly(String role, Boolean includeDefaults), hasRoleFromList(String roles, Boolean includeDefaults), hasRoles(Boolean includeDefaults), lastName, GlideUser (client), setClientData(), userName, userID" /><meta name="DC.relation" scheme="URI" content="../../../../../build/applications/concept/api-client.html" /><meta name="DC.relation" scheme="URI" content="../../../../../build/applications/concept/api-implementation-reference.html" /><meta name="DC.relation" scheme="URI" content="../../../../../build/applications/concept/api-reference.html" /><meta name="DC.creator" content="ServiceNow" /><meta name="DC.date.created" content="2023-08-03" /><meta name="DC.date.modified" content="2024-08-01" /><meta name="DC.format" content="XHTML" /><meta name="DC.identifier" content="c_GlideUserAPI" /><link rel="stylesheet" type="text/css" href="../../../../../CSS/commonltr.css" /><title>GlideUser - Client</title></head><body> <div class="nested0" id="c_GlideUserAPI"> <h1 class="title topictitle1" id="ariaid-title1">GlideUser <span class="ph">- Client</span></h1> <div class="body conbody"><p class="shortdesc">The <span class="keyword apiname">GlideUser</span> API provides methods that access information about the current user and current user roles. Using this API avoids the need to use the slower GlideRecord queries to get user information.</p> <p class="p"><span class="keyword apiname">GlideUser</span> methods and properties are accessed through a global object (<code class="ph codeph">g_user</code>) that is only available in client scripts.</p> <div class="p">This API:<ul class="ul" id="c_GlideUserAPI__ul_bqz_wch_vs"><li class="li">contains name and role information about the current user.</li><li class="li">is typically used in client scripts and UI policies but is also found in UI actions that run on the client.</li><li class="li">cannot be used in business rules or UI actions that run on the server.</li></ul> </div> <p class="p">Session information about the current user and current user roles is contained in the client (web browser). All <span class="keyword apiname">GlideUser</span> methods except <span class="keyword apiname">getClientData()</span> access the session information that is available by default. The <span class="keyword apiname">getClientData()</span> method requires setup on the server and use of the <span class="keyword apiname">putClientData()</span> method to make session information available.</p> <p class="p">For information on using client-side scripts, see <a class="xref" href="https://developer.servicenow.com/dev.do#!/learn/courses/sandiego/app_store_learnv2_scripting_rome_scripting_in_servicenow/app_store_learnv2_scripting_rome_client_side_scripting/app_store_learnv2_scripting_rome_introduction_to_client_side_scripting" target="_blank" rel="noopener noreferrer">Introduction to Client-side Scripting</a>.</p> </div> <div class="related-links"> <div class="familylinks"> <div class="parentlink"><strong>Parent Topic:</strong> <a class="link" href="../../../../../build/applications/concept/api-client.html" title="Use client-side JavaScript APIs to control aspects of how ServiceNow AI Platform is displayed and functions within the web browser. This reference lists available classes and methods along with parameters, descriptions, and examples to help control the end-user experience.">Client API reference</a></div> </div> </div><div class="topic reference nested1 api-field" id="r_GlideUserFirstName"> <h2 class="title topictitle2" id="ariaid-title2">GlideUser - firstName</h2> <div class="body refbody"><p class="shortdesc">The current user's first name.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUserFirstName__table_yrj_5fh_vs" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 1. </span>Field</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e195">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e198">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e201">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e195 ">firstName</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e198 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e201 ">Current user's first name.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>alert('first name = ' + g_user.firstName);</code></pre> </div> </div> </div> <div class="topic reference nested1 api-method" id="r_GlideUser-getClientData_string"> <h2 class="title topictitle2" id="ariaid-title3">GlideUser - getClientData(String key)</h2> <div class="body refbody"><p class="shortdesc">Returns a client value set using <span class="keyword apiname">setClientData()</span> or <span class="keyword apiname">GlideSession -- putClientData()</span>.</p> <div class="section"> <p class="p">Session client data is a set of named strings that may be setup on the server using <a class="xref" href="../../GlideSessionScoped/concept/c_GlideSessionScopedAPI.html" title="The scoped GlideSession API provides methods to find information about the current session."><span class="keyword apiname">GlideSession -- putClientData()</span></a>. You can use <span class="keyword apiname">getClientData()</span> during form load time to get information that the client script needs to make decisions about the form. For example, to identify which fields should be visible.</p> <p class="p">See also <a class="xref" href="../../GlideForm/concept/c_GlideFormAPI.html" title="The GlideForm API provides methods to customize forms."><span class="keyword apiname">GlideForm</span></a>.</p> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-getClientData_string__table_nv5_3k3_ws" class="table parameters" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 2. </span>Parameters</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e327">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e330">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e333">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e327 ">key</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e330 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e333 ">Name of the client data to retrieve.</td></tr></tbody></table> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-getClientData_string__table_ov5_3k3_ws" class="table returns" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 3. </span>Returns</span></caption><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e370">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e373">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e370 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e373 ">Value of the client data.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var loginLanguage = g_user.getClientData("loginlanguage");</code></pre> </div> </div> </div> <div class="topic reference nested1 api-method" id="r_GlideUser-getFullName"> <h2 class="title topictitle2" id="ariaid-title4">GlideUser - getFullName()</h2> <div class="body refbody"><p class="shortdesc">Returns the first and last name of the current user.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-getFullName__table_pvh_cm3_ws" class="table parameters" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 4. </span>Parameters</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e460">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e463">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e466">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e460 ">None</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e463 "> </td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e466 "> </td></tr></tbody></table> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-getFullName__table_qvh_cm3_ws" class="table returns" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 5. </span>Returns</span></caption><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e501">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e504">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e501 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e504 ">The current user's full name.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var formalName = g_user.getFullName();</code></pre> </div> </div> </div> <div class="topic reference nested1 api-method" id="r_GlideUser-hasRole_String"> <h2 class="title topictitle2" id="ariaid-title5">GlideUser - hasRole(String role, Boolean includeDefaults)</h2> <div class="body refbody"><p class="shortdesc">Returns true if the current user has the specified role or the admin role.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRole_String__table_p1w_4m3_ws" class="table parameters" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 6. </span>Parameters</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e590">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e593">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e596">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e590 ">role</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e593 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e596 ">Role to check.</td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e590 ">includeDefaults</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e593 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e596 ">Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see <a class="xref" href="https://docs.servicenow.com/csh?topicname=exploring-user-administration&version=xanadu&pubname=xanadu-platform-administration" target="_blank" rel="noopener noreferrer">Exploring user administration</a>. <p class="p">Default: false</p> </td></tr></tbody></table> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRole_String__table_q1w_4m3_ws" class="table returns" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 7. </span>Returns</span></caption><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e651">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e654">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e651 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e654 ">Returns true if the current user has the specified role or the admin role; otherwise returns false.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var isInternal = g_user.hasRole('snc_internal', true);</code></pre> </div> <div class="example"> <pre class="pre codeblock"><code>var isItil = g_user.hasRole('itil');</code></pre> </div> </div> </div> <div class="topic reference nested1 api-method" id="r_GlideUser-hasRoleExactly_String"> <h2 class="title topictitle2" id="ariaid-title6">GlideUser - hasRoleExactly(String role, Boolean includeDefaults)</h2> <div class="body refbody"><p class="shortdesc">Determines whether the current user has the specified role.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRoleExactly_String__table_r53_hn3_ws" class="table parameters" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 8. </span>Parameters</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e747">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e750">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e753">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e747 ">includeDefaults</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e750 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e753 ">Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see <p class="p"><a class="xref" href="https://docs.servicenow.com/csh?topicname=explicit-roles&version=xanadu&pubname=xanadu-platform-security" target="_blank" rel="noopener noreferrer">Explicit roles</a>.</p> <p class="p">Default: false</p> </td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e747 ">role</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e750 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e753 ">Role to check.</td></tr></tbody></table> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRoleExactly_String__table_s53_hn3_ws" class="table returns" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 9. </span>Returns</span></caption><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e809">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e812">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e809 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e812 ">Returns true if the current user has the specified role.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var isInternal = g_user.hasRoleExactly('snc_internal', true);</code></pre> </div> <div class="example"> <pre class="pre codeblock"><code>var isItil = g_user.hasRoleExactly('itil');</code></pre> </div> </div> </div> <div class="topic reference nested1 api-method" id="r_GlideUser-hasRoleFromList_String"> <h2 class="title topictitle2" id="ariaid-title7">GlideUser - hasRoleFromList(String roles, Boolean includeDefaults)</h2> <div class="body refbody"><p class="shortdesc">Returns true if the current user has at least one of the specified roles or has the admin role.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRoleFromList_String__table_oxf_wn3_ws" class="table parameters" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 10. </span>Parameters</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e904">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e907">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e910">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e904 ">roles</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e907 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e910 ">Comma-separated list of roles to check</td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e904 ">includeDefaults</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e907 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e910 ">Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see <a class="xref" href="https://docs.servicenow.com/csh?topicname=exploring-user-administration&version=xanadu&pubname=xanadu-platform-administration" target="_blank" rel="noopener noreferrer">Exploring user administration</a>. <p class="p">Default: false</p> </td></tr></tbody></table> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRoleFromList_String__table_pxf_wn3_ws" class="table returns" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 11. </span>Returns</span></caption><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e965">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e968">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e965 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e968 ">Returns true if the current user has a role in the list or the admin role.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var isOK = g_user.hasRoleFromList("itil, maint");</code></pre> </div> <div class="example"> <pre class="pre codeblock"><code>var isOK = g_user.hasRoleFromList("itil, maint, snc_internal", true);</code></pre> </div> </div> </div> <div class="topic reference nested1 api-method" id="r_GlideUser-hasRoles"> <h2 class="title topictitle2" id="ariaid-title8">GlideUser - hasRoles(Boolean includeDefaults)</h2> <div class="body refbody"><p class="shortdesc">Returns true if the current user has any role.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRoles__table_ups_k43_ws" class="table parameters" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 12. </span>Parameters</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1061">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1064">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1067">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1061 ">includeDefaults</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1064 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1067 ">Optional. Flag that indicates whether to include default roles, such as snc_internal and snc_external, in the request. For additional information on roles, see <a class="xref" href="https://docs.servicenow.com/csh?topicname=exploring-user-administration&version=xanadu&pubname=xanadu-platform-administration" target="_blank" rel="noopener noreferrer">Exploring user administration</a>. <p class="p">Default: false</p> </td></tr></tbody></table> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-hasRoles__table_vps_k43_ws" class="table returns" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 13. </span>Returns</span></caption><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1110">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1113">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1110 ">Boolean</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1113 ">Returns true if the current user has at least one role.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var yesRole = g_user.hasRoles();</code></pre> </div> <div class="example"> <pre class="pre codeblock"><code>var yesRole = g_user.hasRoles(true);</code></pre> </div> </div> </div> <div class="topic reference nested1 api-field" id="r_GlideUserLastName"> <h2 class="title topictitle2" id="ariaid-title9">GlideUser - lastName</h2> <div class="body refbody"><p class="shortdesc">The current user's last name.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUserLastName__table_g2n_dgh_vs" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 14. </span>Field</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1205">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1208">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1211">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1205 ">lastName</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1208 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1211 ">Current user's last name.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>alert('last name = ' + g_user.lastName);</code></pre> </div> </div> </div> <div class="topic reference nested1 api-method" id="r_GlideUser-setClientData_S_S"> <h2 class="title topictitle2" id="ariaid-title10">GlideUser - setClientData(String key, String value)</h2> <div class="body refbody"><p class="shortdesc">Sets a client value that you can retrieve using <span class="keyword apiname">getClientData()</span>.</p> <div class="section"> <p class="p">See also <a class="xref" href="../../GlideForm/concept/c_GlideFormAPI.html" title="The GlideForm API provides methods to customize forms."><span class="keyword apiname">GlideForm</span></a>.</p> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-setClientData_S_S__table_nv5_3k3_ws" class="table parameters" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 15. </span>Parameters</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1318">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1321">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1324">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1318 ">key</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1321 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1324 ">Name of the client data to store as a key.</td></tr><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1318 ">value</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1321 ">Number</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1324 ">Value to assign to the key.</td></tr></tbody></table> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUser-setClientData_S_S__table_ov5_3k3_ws" class="table returns" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 16. </span>Returns</span></caption><colgroup><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1373">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1376">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1373 ">None</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1376 "> </td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>function onSubmit() { if (!g_user.getClientData('keyName')) { var now_GR = new GlideRecord('incident'); now_GR.addActiveQuery(); now_GR.setLimit(1); now_GR.query(cb); return false; } return true; } function cb(now_GR) { // <insert glide operation > g_user.setClientData('keyName', now_GR.getValue('<number>')); g_form.submit(); }</code></pre> </div> </div> </div> <div class="topic reference nested1 api-field" id="r_GlideUserUserName"> <h2 class="title topictitle2" id="ariaid-title11">GlideUser - userName</h2> <div class="body refbody"><p class="shortdesc">The current user's username, for example gsmith02. It is not the user's name, for example George Smith.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUserUserName__table_sf4_t2h_vs" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 17. </span>Field</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1461">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1464">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1467">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1461 ">userName</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1464 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1467 ">Current user's username.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var userName = g_user.userName; alert('Current user = ' + userName);</code></pre> </div> </div> </div> <div class="topic reference nested1 api-field" id="r_GlideUserUserID"> <h2 class="title topictitle2" id="ariaid-title12">GlideUser - userID</h2> <div class="body refbody"><p class="shortdesc">Returns the sys_id of the current user.</p> <div class="section"> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_GlideUserUserID__table_fhb_3fh_vs" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 18. </span>Field</span></caption><colgroup><col /><col /><col /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1557">Name</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1560">Type</th><th class="entry cellrowborder" style="vertical-align:top;" id="d764863e1563">Description</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1557 ">userID</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1560 ">String</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d764863e1563 ">Sys_id of the current user.</td></tr></tbody></table> </div> </div> <div class="example"> <pre class="pre codeblock"><code>var userID = g_user.userID; alert('Current user ID = ' + userID);</code></pre> </div> </div> </div> </div> </body></html></div>