<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Is there a way to hide/show a variable based on the current user's group? in ServiceNow AI Platform forum</title>
    <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137343#M93732</link>
    <description>&lt;P&gt;I still can't get it to work (any ideas?), here is what I have so far:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Script Include (client callable, all application scopes):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var hideCCfield = Class.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;hideCCfield.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; userMember: function(){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if(gs.getUser().isMemberOf('All Managers'))&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return true;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; else&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return false;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; },&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; type: 'hideCCfield'&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;});&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Catalog Client Script (onLoad):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function onLoad() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var ajax = new GlideAjax('hideCCfield');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ajax.getXML(myResponse);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function myResponse(response){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(answer == false){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setDisplay("charge_to_cost_center",false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 21 Apr 2016 16:03:20 GMT</pubDate>
    <dc:creator>jonb</dc:creator>
    <dc:date>2016-04-21T16:03:20Z</dc:date>
    <item>
      <title>Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137340#M93729</link>
      <description>&lt;P&gt;I am needing to hide a variable (that is part of a variable set), unless the current user is a member of a certain group... is this possible?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 15:10:52 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137340#M93729</guid>
      <dc:creator>jonb</dc:creator>
      <dc:date>2016-04-21T15:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137341#M93730</link>
      <description>&lt;P&gt;&lt;A title="Re: Catalog variable should be visible to only 1 or 2 groups" __default_attr="842941" __jive_macro_name="message" class="jive_macro jive_macro_message" data-orig-content="Re: Catalog variable should be visible to only 1 or 2 groups" data-renderedposition="10.449999809265136_8_385_16" href="https://www.servicenow.com/community?id=community_question&amp;amp;sys_id=24e1dbaddbdcdbc01dcaf3231f96190d"&gt;Re: Catalog variable should be visible to only 1 or 2 groups&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A title="Hiding Catalog Item Variables based on Group Membership" __default_attr="169738" __jive_macro_name="thread" class="jive_macro_thread jive_macro" data-orig-content="Hiding Catalog Item Variables based on Group Membership" data-renderedposition="52.44999694824219_8_390_16" href="https://www.servicenow.com/community?id=community_question&amp;amp;sys_id=c97a07e9db5cdbc01dcaf3231f961990"&gt;Hiding Catalog Item Variables based on Group Membership&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 15:15:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137341#M93730</guid>
      <dc:creator>Harish KM</dc:creator>
      <dc:date>2016-04-21T15:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137342#M93731</link>
      <description>&lt;P&gt;Yes; you can do this using GlideAjax. The first example &lt;A title="harishkumar" __default_attr="27705" __jive_macro_name="user" class="jive-link-profile-small jive_macro jive_macro_user" data-id="27705" data-objecttype="3" data-orig-content="harishkumar" data-renderedposition="10_358.703125_99_16" data-type="person" href="https://www.servicenow.com/community?id=community_user_profile&amp;amp;user=7b80522ddb581fc09c9ffb651f9619cc"&gt;harishkumar&lt;/A&gt; posted above points in the right direction. Getting the user object, passing the info to the client script and using the 'g_form.setDisplay' function.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 15:36:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137342#M93731</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2016-04-21T15:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137343#M93732</link>
      <description>&lt;P&gt;I still can't get it to work (any ideas?), here is what I have so far:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Script Include (client callable, all application scopes):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var hideCCfield = Class.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;hideCCfield.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; userMember: function(){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if(gs.getUser().isMemberOf('All Managers'))&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return true;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; else&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return false;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; },&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; type: 'hideCCfield'&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;});&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Catalog Client Script (onLoad):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function onLoad() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var ajax = new GlideAjax('hideCCfield');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ajax.getXML(myResponse);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function myResponse(response){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(answer == false){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setDisplay("charge_to_cost_center",false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 16:03:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137343#M93732</guid>
      <dc:creator>jonb</dc:creator>
      <dc:date>2016-04-21T16:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137344#M93733</link>
      <description>&lt;P&gt;Close; you're missing some key pieces, though. You're not passing the variables and parameters between the scripts. Here's an example of a script I used to query the user record and check their employee level (custom field).&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Script include function:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="_jivemacro_uid_146125837089660 jive_macro_code jive_text_macro" data-renderedposition="113_8_1192_160" jivemacro_uid="_146125837089660"&gt;&lt;P&gt;getUserLevel : function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var userID = this.getParameter('sysparm_userID');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //gs.log("TM===&amp;gt; Getting user record for " + userID);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var gsp = new GlideRecord('sys_user');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; gsp.addQuery('sys_id', userID);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; gsp.query();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if(gsp.next()){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return gsp.u_employee_level;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; },&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Client script:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14612584120706517 jive_text_macro" data-renderedposition="336_8_1192_256" jivemacro_uid="_14612584120706517" modifiedtitle="true"&gt;&lt;P&gt;function onLoad() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //Type appropriate comment here, and begin script below&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var ga = new GlideAjax('MyAjaxUtils');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.addParam('sysparm_name', 'getUserLevel');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.addParam('sysparm_userID', g_user.userID);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.getXML(parseLevel);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; function parseLevel(response) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if (answer &amp;lt; 4) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; g_form.setDisplay('surface_pro_3', false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //alert("User is level " + answer);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;So, you need to first call the function in the client script (in your case, ga.addParam('sysparm_name', 'userMember'), then pass the userID from the form back to the script include.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Hope this makes sense!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 17:11:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137344#M93733</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2016-04-21T17:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137345#M93734</link>
      <description>&lt;P&gt;I thought I had it using yours as a guide, but I still can't get it to work... did I mess up somewhere?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Script Include:&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var hideCCfield = Class.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;hideCCfield.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; userMember: function(){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var userID = this.getParameter('sysparm_userID'); &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; var gsp = new GlideRecord('sys_user'); &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; gsp.addQuery('sys_id', userID); &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; gsp.query(); &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if(gsp.isMemberOf('All Managers')){ &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return true;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; } &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }, &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; type: 'hideCCfield'&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;});&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Catalog Client Script:&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function onLoad() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var ajax = new GlideAjax('hideCCfield');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ga.addParam('sysparm_name', 'userMember');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ga.addParam('sysparm_userID', g_user.userID);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ajax.getXML(myResponse);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;function myResponse(response){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(answer != true){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_form.setDisplay("charge_to_cost_center",false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 18:43:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137345#M93734</guid>
      <dc:creator>jonb</dc:creator>
      <dc:date>2016-04-21T18:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137346#M93735</link>
      <description>&lt;P&gt;Looks close; can you try using 'alert' and log statements to see if your variables are correct?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Script include:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;gs.log("Getting user record for " + userID); &amp;lt;- check the system logs&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Client script:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;alert(answer); -&amp;gt; should be the true/false.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 18:50:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137346#M93735</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2016-04-21T18:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137347#M93736</link>
      <description>&lt;P&gt;The alert was returning 'null'...&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I noticed I goofed on lines 2 and 5 of the client script, the var was referred to as 'ajax' instead of 'ga'.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I fixed that.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;However, the alert is now returning 'false' for both scenarios. &amp;nbsp; I have double (and triple) checked the group name, and even tried using a sys id instead of the name... still returned false for both...&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;if statement:&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if(gsp.isMemberOf('All Managers')) { &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return true; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; } &amp;nbsp; else {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return false;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 19:56:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137347#M93736</guid>
      <dc:creator>jonb</dc:creator>
      <dc:date>2016-04-21T19:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137348#M93737</link>
      <description>&lt;P&gt;Did you add the log statement to the script include? Check to make sure it's querying the correct user. &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;It usually ends up being small things like typos and what not that take the most time to figure out :S&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 20:02:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137348#M93737</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2016-04-21T20:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137349#M93738</link>
      <description>&lt;P&gt;Yeah, the log statement is listing the sys ID of the logged in user (or the person I am impersonating)&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2016 20:19:07 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137349#M93738</guid>
      <dc:creator>jonb</dc:creator>
      <dc:date>2016-04-21T20:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137350#M93739</link>
      <description>&lt;P&gt;Jon,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I finally figured this out, as it was bugging me. One of the things that helps when troubleshooting is using 'Scripts-&amp;gt;Background' (you need to have elevated security). I ran a bunch of script tests in Background and realized you can't just pass a string to 'isMemberOf()', it needs to be an object.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;As an example, this does not work:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14613517012479336" data-renderedposition="155_8_1192_96" jivemacro_uid="_14613517012479336"&gt;&lt;P&gt;var user = 'fd5c7b034f4c020093bd7d218110c7ee';&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if (user.isMemberOf('Service Desk')) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;gs.print(true); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} else {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;gs.print(false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;It always evaluates to false.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This does work, though:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14613517483235876 jive_text_macro" data-renderedposition="356_8_1192_96" jivemacro_uid="_14613517483235876"&gt;&lt;P&gt;var ourUser = gs.getUser().getUserByID('fd5c7b034f4c020093bd7d218110c7ee');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if (ourUser.isMemberOf('Service Desk')) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;gs.print(true); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} else {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;gs.print(false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This evaluates to true.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;So, I modified the script include:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14613518368318982" data-renderedposition="557_8_1192_192" jivemacro_uid="_14613518368318982"&gt;&lt;P&gt;isGrpMember : function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var userID = this.getParameter('sysparm_userID');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var groupName = this.getParameter('sysparm_groupName');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var thisUser = gs.getUser().getUserByID(userID);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //gs.log("TM ===&amp;gt; " + thisUser + " | " + groupName, "Q: isGrpMember Ajax"); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if (thisUser.isMemberOf(groupName)) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return true; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; } else {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; return false;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; },&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Client script:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14613518856274065 jive_text_macro" data-renderedposition="812_8_1192_304" jivemacro_uid="_14613518856274065" modifiedtitle="true"&gt;&lt;P&gt;function onLoad() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; //Type appropriate comment here, and begin script below&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var ga = new GlideAjax('MyAjaxUtils');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.addParam('sysparm_name', 'isGrpMember');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.addParam('sysparm_userID', g_user.userID);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.addParam('sysparm_groupName', 'Service Desk');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; ga.getXML(hideField); &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; // Callback function to process the response returned from the server&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; function hideField(response) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; alert(answer);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; if (answer == 'false') {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; g_form.setDisplay('field4', false);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; } &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This worked for me on a test catalogue item with some fields. Hopefully this works for you as well. I added the 'sysparm_groupName' to make it a little more re-usable; instead of specifying the group in the script include, you can reuse the function in multiple client scripts with different groups passed to the script. &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I found this article which had a similar example which someone noted did not work:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A title="ismemberOf question" __default_attr="899035" __jive_macro_name="message" class="jive_macro jive_macro_message" data-orig-content="ismemberOf question" data-renderedposition="1244_8_155_16" href="https://www.servicenow.com/community?id=community_question&amp;amp;sys_id=8f7087e1db98dbc01dcaf3231f9619bc"&gt;ismemberOf question&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Anyways, hope that helps!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Tim &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Apr 2016 19:10:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137350#M93739</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2016-04-22T19:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to hide/show a variable based on the current user's group?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137351#M93740</link>
      <description>&lt;P&gt;This worked perfectly!!! Thank you!!!&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Apr 2016 15:50:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/is-there-a-way-to-hide-show-a-variable-based-on-the-current-user/m-p/1137351#M93740</guid>
      <dc:creator>jonb</dc:creator>
      <dc:date>2016-04-23T15:50:53Z</dc:date>
    </item>
  </channel>
</rss>

