<?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: Hide Variable set based on users location in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419710#M76636</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;you should be using onChange catalog client script on Requested For variable which is in Variable Set&lt;/P&gt;
&lt;P&gt;Applies to Variable Set&lt;/P&gt;
&lt;P&gt;Select Variable&lt;/P&gt;
&lt;P&gt;I could not see region field on sys_user or location table; if that's custom field then use that correctly&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Script Include: It should be client callable&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note: You use correct field for type and region based on correct table&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	checkRecordPresent: function(){
		var id = this.getParameter('sysparm_userID');			
		var gr = new GlideRecord('sys_user');
		gr.addQuery('sys_id', id);
		gr.query();
		if(gr.next()){
			if(gr.location.type == 'ABC' &amp;amp;&amp;amp; (gr.u_region == 'XYZ' || gr.location.u_region == 'XYZ'))
				return 'show';
			else
				return 'hide';
		}
	},

	type: 'checkRecords'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Client Script:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onChange(control, oldValue, newValue, isLoading) {

	if(oldValue != newValue){
		var ga = new GlideAjax('checkRecords');
		ga.addParam('sysparm_name', 'checkRecordPresent');
		ga.addParam('sysparm_userID', newValue); 
		ga.getXMLAnswer(function(answer){
			if(answer == 'show'){
				// show variable set

			}else{
				// hide variable set
			}
		});
	}
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 12:05:20 GMT</pubDate>
    <dc:creator>Ankur Bawiskar</dc:creator>
    <dc:date>2022-02-14T12:05:20Z</dc:date>
    <item>
      <title>Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419705#M76631</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;Can anyone please help us on the below requirement.&lt;/P&gt;
&lt;P&gt;We developed one catalog item&amp;nbsp;with&amp;nbsp;few variables and 2 variables sets. [example: C and D sets]&lt;/P&gt;
&lt;P&gt;and now&amp;nbsp;we want to&amp;nbsp;visible the "&lt;STRONG&gt;D"&lt;/STRONG&gt; variable set only&amp;nbsp;if the &lt;STRONG&gt;requested for [&lt;/STRONG&gt;var in &lt;STRONG&gt;"C"&lt;/STRONG&gt; variable set&lt;STRONG&gt;]&lt;/STRONG&gt; user Region is XYZ and Location Type is ABC.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NOte: Both Region and Location type fields are available in Location (cmn_location) table.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;what is the best way to do it.??&lt;/P&gt;
&lt;P&gt;Many thanks for the support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Feb 2022 07:40:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419705#M76631</guid>
      <dc:creator>ar1</dc:creator>
      <dc:date>2022-02-13T07:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419706#M76632</link>
      <description>&lt;P&gt;Hi Ar,&lt;/P&gt;
&lt;P&gt;You can create an on change client script.&lt;/P&gt;
&lt;P&gt;By checking the value of g_form.getValue(variable.). And then make the other set of variables visible true.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Hope this will be helpful.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Feb 2022 07:59:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419706#M76632</guid>
      <dc:creator>Rajat_Choudhary</dc:creator>
      <dc:date>2022-02-13T07:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419707#M76633</link>
      <description>&lt;P&gt;Please try the solution provided in this link according to your needs. Thanks!&lt;/P&gt;
&lt;P&gt;https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=053abcd8dbcdd3040e3dfb651f961987&lt;/P&gt;</description>
      <pubDate>Sun, 13 Feb 2022 08:40:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419707#M76633</guid>
      <dc:creator>Guna Shalini M</dc:creator>
      <dc:date>2022-02-13T08:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419708#M76634</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please follow the steps below:&lt;/P&gt;
&lt;P&gt;1) Create a Client Callable Script Include and use the script as below:&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;var getLocation = Class.create();
getLocation.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	getLocationDetails: function(){
		var getRequestor = this.getParameter('sysparm_requestor');
		var gr = new GlideRecord('sys_user');
		gr.addQuery('sys_id',getRequestor);
		gr.query();
		if(gr.next()){
			var getLoc = this._getLocationDetails(gr.location);
		}
		return getLoc;
	},
	
	_getLocationDetails : function(locID){
		var gr1 =  new GlideRecord('cmn_location');
		gr1.addQuery('sys_id',locID);
		gr1.query();
		if(gr1.next()){
			var obj = {};
			obj.LOCNAME = gr1.getValue('name').toString();
			obj.Region = gr1.getValue('region').toString(); // Replace "region" with your Region field Name present in Location Table
		}
		return JSON.stringify(obj);
	},

    type: 'getLocation'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/152164i08A6AF60E3E6C9FD/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now Create an On Load Client Script on your Requested Item or on the table where you want to hide the variables and use the script as below:&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;function onLoad() {
    //Type appropriate comment here, and begin script below
    var ga = new GlideAjax('getLocation');
    ga.addParam('sysparm_name', 'getLocationDetails');
    ga.addParam('sysparm_requestor', g_form.getValue('variables.variableName')); // Replace Variable name with Requestor For variable
    ga.getXML(getLoc);

    function getLoc(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
		var parseAnswer = JSON.parse(answer);
		if(parseAnswer.LOCNAME == 'Enter your value of Location Name here' &amp;amp;&amp;amp; parseAnswer.Region == 'Enter Region value here'){
			g_form.setDisplay('variables.VariableName1',true); // Enter your variable Name which you want to show present in Variable Set C and below also replace other variables
			g_form.setDisplay('variables.VariableName1',true);
			g_form.setDisplay('variables.VariableName1',true);
		}else{
			g_form.setDisplay('variables.VariableName1',false); //If condition does not match then it will hide the variables.
			g_form.setDisplay('variables.VariableName1',false);
			g_form.setDisplay('variables.VariableName1',false);
		}
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/152156i14C5C93658BC776D/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Let me know if you are facing an issue here.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hope this helps. Please mark the answer as correct/helpful based on impact.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Shloke&lt;/P&gt;</description>
      <pubDate>Sun, 13 Feb 2022 10:03:46 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419708#M76634</guid>
      <dc:creator>shloke04</dc:creator>
      <dc:date>2022-02-13T10:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419709#M76635</link>
      <description>&lt;P&gt;Hi Shloke,&lt;/P&gt;
&lt;P&gt;Thanks for the response.&lt;/P&gt;
&lt;P&gt;We tried the above code but some reasons it's not working properly.&lt;/P&gt;
&lt;P&gt;Could you pls check the below code once and&amp;nbsp; let us know any changes are required.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Client script:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;function onLoad() {&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; var ga = new GlideAjax('getLocation');&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; ga.addParam('sysparm_name', 'getLocationDetails');&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; ga.addParam('sysparm_requestor', g_form.getValue('caller_id'));&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; ga.getXML(getLoc);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;function getLoc(response) {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; var parseAnswer = JSON.parse(answer);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; alert(parseAnswer);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; if(parseAnswer.LOCNAME == 'ABC' &amp;amp;&amp;amp; parseAnswer.Region == 'XYZ'){&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; g_form.setDisplay('sap_variables_updated',true);&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; g_form.setDisplay('SAP Variables Updated',true);&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;}else{&lt;/STRONG&gt;&lt;BR /&gt; &lt;STRONG&gt;g_form.setDisplay('sap_variables_updated',false); &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; g_form.setDisplay('SAP Variables Updated',false);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note: Client script Alert we're getting as "object".&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Script&amp;nbsp; include:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Clientcallablle --&amp;gt; True&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var getLocation = Class.create();&lt;BR /&gt;getLocation.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;BR /&gt; &lt;BR /&gt; getLocationDetails: function(){&lt;BR /&gt; var getRequestor = this.getParameter('sysparm_requestor');&lt;BR /&gt; var gr = new GlideRecord('sys_user');&lt;BR /&gt; gr.addQuery('sys_id',getRequestor);&lt;BR /&gt; gr.query();&lt;BR /&gt; if(gr.next()){&lt;BR /&gt; var getLoc = this._getLocationDetails(gr.location);&lt;BR /&gt; }&lt;BR /&gt; return getLoc;&lt;BR /&gt; },&lt;BR /&gt; &lt;BR /&gt; _getLocationDetails : function(locID){&lt;BR /&gt; var gr1 = new GlideRecord('cmn_location');&lt;BR /&gt; gr1.addQuery('sys_id',locID);&lt;BR /&gt; gr1.query();&lt;BR /&gt; if(gr1.next()){&lt;BR /&gt; var obj = {};&lt;BR /&gt; obj.LOCNAME = gr1.getValue('u_location_type').toString();&lt;BR /&gt; obj.Region = gr1.getValue('u_region').toString(); // Replace "region" with your Region field Name present in Location Table&lt;BR /&gt; }&lt;BR /&gt; return JSON.stringify(obj);&lt;BR /&gt; },&lt;/P&gt;
&lt;P&gt;type: 'getLocation'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks for the support.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 11:53:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419709#M76635</guid>
      <dc:creator>ar1</dc:creator>
      <dc:date>2022-02-14T11:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419710#M76636</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;you should be using onChange catalog client script on Requested For variable which is in Variable Set&lt;/P&gt;
&lt;P&gt;Applies to Variable Set&lt;/P&gt;
&lt;P&gt;Select Variable&lt;/P&gt;
&lt;P&gt;I could not see region field on sys_user or location table; if that's custom field then use that correctly&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Script Include: It should be client callable&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note: You use correct field for type and region based on correct table&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	checkRecordPresent: function(){
		var id = this.getParameter('sysparm_userID');			
		var gr = new GlideRecord('sys_user');
		gr.addQuery('sys_id', id);
		gr.query();
		if(gr.next()){
			if(gr.location.type == 'ABC' &amp;amp;&amp;amp; (gr.u_region == 'XYZ' || gr.location.u_region == 'XYZ'))
				return 'show';
			else
				return 'hide';
		}
	},

	type: 'checkRecords'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Client Script:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onChange(control, oldValue, newValue, isLoading) {

	if(oldValue != newValue){
		var ga = new GlideAjax('checkRecords');
		ga.addParam('sysparm_name', 'checkRecordPresent');
		ga.addParam('sysparm_userID', newValue); 
		ga.getXMLAnswer(function(answer){
			if(answer == 'show'){
				// show variable set

			}else{
				// hide variable set
			}
		});
	}
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 12:05:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419710#M76636</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2022-02-14T12:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419711#M76637</link>
      <description>&lt;P&gt;Hi Ankur,&lt;/P&gt;
&lt;P&gt;Thanks for the response.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Region&lt;/STRONG&gt;&amp;nbsp;and &lt;STRONG&gt;Location Type&lt;/STRONG&gt; fields are available in Location(cmn_location) table in our instance.&lt;/P&gt;
&lt;P&gt;We tried your code but it's not working.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Requested for&lt;/STRONG&gt; backed value is &lt;STRONG&gt;caller_id &lt;/STRONG&gt;and it's available in &lt;STRONG&gt;User order details&lt;/STRONG&gt; variable set.&lt;/P&gt;
&lt;P&gt;Based on the &lt;STRONG&gt;Requested for'S&lt;/STRONG&gt;&amp;nbsp;Region and Location Type we want to show and hide the another variable set called:&amp;nbsp;SAP Variables Updated&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;CScript&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/152160i342B9AB846BB5C05/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;function onChange(control, oldValue, newValue, isLoading) {&lt;/P&gt;
&lt;P&gt;if(oldValue != newValue){&lt;BR /&gt; var ga = new GlideAjax('checkRecords');&lt;BR /&gt; ga.addParam('sysparm_name', 'checkRecordPresent');&lt;BR /&gt; ga.addParam('sysparm_userID', newValue); &lt;BR /&gt; ga.getXMLAnswer(function(answer){&lt;BR /&gt; if(answer == 'show'){&lt;BR /&gt;g_form.setDisplay('sap_variables_updated',true); &lt;BR /&gt;g_form.setDisplay('SAP Variables Updated',true);&lt;BR /&gt; }else{&lt;BR /&gt;g_form.setDisplay('sap_variables_updated',false); &lt;BR /&gt;g_form.setDisplay('SAP Variables Updated',false); }&lt;BR /&gt; });&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script Include:&lt;/P&gt;
&lt;P&gt;var checkRecords = Class.create();&lt;BR /&gt;checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;/P&gt;
&lt;P&gt;checkRecordPresent: function(){&lt;BR /&gt; var id = this.getParameter('sysparm_userID'); &lt;BR /&gt; var gr = new GlideRecord('cmn_location');&lt;BR /&gt; gr.addQuery('sys_id', id);&lt;BR /&gt; gr.query();&lt;BR /&gt; if(gr.next()){&lt;BR /&gt; if(gr.u_location_type == 'XYZ' &amp;amp;&amp;amp; gr.u_region == 'ABC')&lt;BR /&gt; return 'show';&lt;BR /&gt; else&lt;BR /&gt; return 'hide';&lt;BR /&gt; }&lt;BR /&gt; },&lt;/P&gt;
&lt;P&gt;type: 'checkRecords'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Advacne thanks&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 12:19:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419711#M76637</guid>
      <dc:creator>ar1</dc:creator>
      <dc:date>2022-02-14T12:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419712#M76638</link>
      <description>&lt;P&gt;Not an issue. We can debug this and get you to a solution here.&lt;/P&gt;
&lt;P&gt;Couple of things to look here in order to fix this:&lt;/P&gt;
&lt;P&gt;1) Client Script: Can you put two alert here in your client script and show me what value you are getting .&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;alert(parseAnswer.LOCNAME);
alert(parseAnswer.Region);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should be placed just after this line of code :&amp;nbsp;&lt;STRONG&gt;var parseAnswer = JSON.parse(answer);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Also in your Script Include put a log to confirm what value are getting returned from your Script include here:&lt;/P&gt;
&lt;P&gt;I have updated Script Include for you with Log Statement so try it and let me know what value are getting printed in Log:&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;var getLocation = Class.create();
getLocation.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getLocationDetails: function(){
var getRequestor = this.getParameter('sysparm_requestor');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',getRequestor);
gr.query();
if(gr.next()){
var getLoc = this._getLocationDetails(gr.location);
}
gs.info('3333' + getLoc);
return getLoc;
},

_getLocationDetails : function(locID){
var gr1 = new GlideRecord('cmn_location');
gr1.addQuery('sys_id',locID);
gr1.query();
if(gr1.next()){
var obj = {};
obj.LOCNAME = gr1.getValue('u_location_type').toString();
obj.Region = gr1.getValue('u_region').toString(); // Replace "region" with your Region field Name present in Location Table
}
gs.info('1111 ' + obj.LOCNAME);
gs.info('2222' + obj.Region);
return JSON.stringify(obj);
},

type: 'getLocation'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let me know both alert an log placed in both script what you are getting. Sharing a screenshot will help me to debug this for you.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hope this helps. Please mark the answer as correct/helpful based on impact.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Shloke&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 13:37:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419712#M76638</guid>
      <dc:creator>shloke04</dc:creator>
      <dc:date>2022-02-14T13:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Hide Variable set based on users location</title>
      <link>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419713#M76639</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;your variable is referring to sys_user but you are querying cmn_location&lt;/P&gt;
&lt;P&gt;so query sys_user as you can dot walk the location field to get the other fields&lt;/P&gt;
&lt;P&gt;var checkRecords = Class.create();&lt;BR /&gt;checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;checkRecordPresent: function(){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;var id = this.getParameter('sysparm_userID');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;var gr = new GlideRecord('&lt;STRONG&gt;sys_user&lt;/STRONG&gt;');&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;gr.addQuery('sys_id', id);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;gr.query();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(gr.next()){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(gr.&lt;STRONG&gt;location&lt;/STRONG&gt;.u_location_type == 'XYZ' &amp;amp;&amp;amp; gr.&lt;STRONG&gt;location&lt;/STRONG&gt;.u_region == 'ABC')&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return 'show';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return 'hide';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;},&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;type: 'checkRecords'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 13:43:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/hide-variable-set-based-on-users-location/m-p/1419713#M76639</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2022-02-14T13:43:55Z</dc:date>
    </item>
  </channel>
</rss>

