<?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: How to use GlideAjax? in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3512003#M6437</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1063032"&gt;@ayushaggarw&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Hope you are doing well.&lt;BR /&gt;&lt;BR /&gt;Try to use the below code snippets.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. The Script Include :&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;You must check the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;"Client callable"&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;box.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Step 2:&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;var UserDetailsUtils = Class.create();
UserDetailsUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, { // Connects to the Ajax system

    getDept: function() {
        // 1. Get the User ID 
        var userId = this.getParameter('sysparm_user_id');
        
        // 2. Look up the User record in the database
        var userGR = new GlideRecord('sys_user');
        if (userGR.get(userId)) {
            // 3. Get the "Department" name
            var department = userGR.getDisplayValue('department');
            
            // 4. Return it, or a message if empty 
            return department ? department : "No Department Assigned";
        }
        return "";
    },

    type: 'UserDetailsUtils'
});&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&amp;nbsp;Step 3&lt;/STRONG&gt;:&amp;nbsp;&lt;SPAN&gt;The Client Script&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;Type&lt;/STRONG&gt; :&amp;nbsp;onChange&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;Field name: &lt;/STRONG&gt;Caller&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;STRONG&gt;Step 4 :&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        g_form.setValue('u_caller_department', ''); // Clear your custom field
        return;
    }

    // 1. Start the "GlideAjax" request
    var ga = new GlideAjax('UserDetailsUtils'); // Name of the Script Include
    ga.addParam('sysparm_name', 'getDept');      // Name of the function to run
    ga.addParam('sysparm_user_id', newValue);    // Pass the new Caller's sys_id

    // 2. Send the request and wait for the "answer" (getXMLAnswer is the modern way)
    ga.getXMLAnswer(function(answer) {
        if (answer) {
            // 3. Populate your custom field with the result 
            g_form.setValue('u_caller_department', answer);
        }
    });
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Use the above code to get your solution. If you find it helpful for you please mark it as helpful.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Sagnic&lt;/P&gt;</description>
    <pubDate>Sat, 21 Mar 2026 06:34:21 GMT</pubDate>
    <dc:creator>Its_Sagnic</dc:creator>
    <dc:date>2026-03-21T06:34:21Z</dc:date>
    <item>
      <title>How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511255#M6425</link>
      <description>&lt;P&gt;I have a task -&amp;nbsp;&lt;BR /&gt;When a user selects a Caller on an Incident form, the system should fetch the caller's department from the server&lt;BR /&gt;and populate a custom field on the form without reloading the page. Design the solution using a client callable&lt;BR /&gt;Script Include and a client script.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Conditions / expectations:&lt;BR /&gt;• Do not hardcode department values in the client script.&lt;BR /&gt;• Use GlideAjax for communication.&lt;BR /&gt;• Handle the case where the user has no department.&lt;BR /&gt;Success criteria: A working client-side interaction where the department is fetched from the server and populated&lt;BR /&gt;correctly.&lt;BR /&gt;&lt;BR /&gt;I created column in incident table and create client script and script include and select the user with department but it does not autofill in the incident table why anyone help me out of this?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2026 02:16:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511255#M6425</guid>
      <dc:creator>ayushaggarw</dc:creator>
      <dc:date>2026-03-20T02:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511936#M6432</link>
      <description>&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2323817" target="_blank"&gt;https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2323817&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2026 20:56:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511936#M6432</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2026-03-20T20:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511993#M6434</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1063032"&gt;@ayushaggarw&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can below code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;client script :&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   var ga=new GlideAjax('getDepartment');
   ga.addParam('sysparm_name','getUserData');
   ga.addParam('sysparm_user',newValue);
   ga.getXMLAnswer(function(res){
	g_form.setValue('short_description',res)
// here i set department value in short description , you can set in your custom field
   })

   //Type appropriate comment here, and begin script below
   
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot (1190).png" style="width: 999px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/507037iD0BBA36121987558/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (1190).png" alt="Screenshot (1190).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script include :&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var getDepartment = Class.create();
getDepartment.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getUserData: function() {
        var gr = new GlideRecord('sys_user');
		gs.log(this.getParameter('sysparm_user'))
        if (gr.get(this.getParameter('sysparm_user'))) {
            if (gr.department) {
                return gr.getDisplayValue("department").toString();
				
            }
			else{
				gs.addErrorMessage('No valid department exist')
			}

        }
    },
    type: 'getDepartment'
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot (1189).png" style="width: 999px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/507038iDFC7F570CAB770A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (1189).png" alt="Screenshot (1189).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this helps you then mark it as helpful and accept as solution.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aditya&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2026 05:51:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511993#M6434</guid>
      <dc:creator>Aditya_hublikar</dc:creator>
      <dc:date>2026-03-21T05:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511995#M6435</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1063032"&gt;@ayushaggarw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Client Script&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Table: Incident&lt;BR /&gt;Type: onChange&lt;BR /&gt;Field name: Caller&lt;BR /&gt;Script:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading, isTemplate) {

	if(isLoading) {
		return;
	}

	if(newValue === '') {
		g_form.clearValue('u_custom_department');
	}

	var gaPhone = new GlideAjax('getUserPropertiesAjax');
	gaPhone.addParam('sysparm_name', 'get_department');
	gaPhone.addParam('sysparm_user', newValue);
	gaPhone.getXMLAnswer(_handleResponse);

	function _handleResponse(response) {
		var answer = response;
		
		g_form.setValue('u_custom_department', answer);
	}

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Script Include&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Name: getUserPropertiesAjax&lt;BR /&gt;Client callable: true&lt;BR /&gt;Script:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var getUserPropertiesAjax = Class.create();
getUserPropertiesAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	get_department : function() {
		var grUser = new GlideRecord('sys_user');

		if(grUser.get(this.getParameter('sysparm_user'))) {
			return grUser.getValue('department');
		}
	},
	
    type: 'getUserPropertiesAjax'
	
});&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 21 Mar 2026 06:09:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511995#M6435</guid>
      <dc:creator>Tanushree Maiti</dc:creator>
      <dc:date>2026-03-21T06:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511999#M6436</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1063032"&gt;@ayushaggarw&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Review the link-&amp;nbsp;&lt;A href="https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430" target="_blank"&gt;https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If you found my response helpful &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;, please mark it as helpful &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; and accept it as the solution &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you! &lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;BR /&gt;Nawal Singh&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2026 06:26:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3511999#M6436</guid>
      <dc:creator>nawalkishos</dc:creator>
      <dc:date>2026-03-21T06:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3512003#M6437</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1063032"&gt;@ayushaggarw&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Hope you are doing well.&lt;BR /&gt;&lt;BR /&gt;Try to use the below code snippets.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. The Script Include :&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Step 1:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;You must check the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;"Client callable"&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;box.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Step 2:&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;var UserDetailsUtils = Class.create();
UserDetailsUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, { // Connects to the Ajax system

    getDept: function() {
        // 1. Get the User ID 
        var userId = this.getParameter('sysparm_user_id');
        
        // 2. Look up the User record in the database
        var userGR = new GlideRecord('sys_user');
        if (userGR.get(userId)) {
            // 3. Get the "Department" name
            var department = userGR.getDisplayValue('department');
            
            // 4. Return it, or a message if empty 
            return department ? department : "No Department Assigned";
        }
        return "";
    },

    type: 'UserDetailsUtils'
});&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&amp;nbsp;Step 3&lt;/STRONG&gt;:&amp;nbsp;&lt;SPAN&gt;The Client Script&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;Type&lt;/STRONG&gt; :&amp;nbsp;onChange&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;Field name: &lt;/STRONG&gt;Caller&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;STRONG&gt;Step 4 :&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        g_form.setValue('u_caller_department', ''); // Clear your custom field
        return;
    }

    // 1. Start the "GlideAjax" request
    var ga = new GlideAjax('UserDetailsUtils'); // Name of the Script Include
    ga.addParam('sysparm_name', 'getDept');      // Name of the function to run
    ga.addParam('sysparm_user_id', newValue);    // Pass the new Caller's sys_id

    // 2. Send the request and wait for the "answer" (getXMLAnswer is the modern way)
    ga.getXMLAnswer(function(answer) {
        if (answer) {
            // 3. Populate your custom field with the result 
            g_form.setValue('u_caller_department', answer);
        }
    });
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Use the above code to get your solution. If you find it helpful for you please mark it as helpful.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Sagnic&lt;/P&gt;</description>
      <pubDate>Sat, 21 Mar 2026 06:34:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3512003#M6437</guid>
      <dc:creator>Its_Sagnic</dc:creator>
      <dc:date>2026-03-21T06:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3512456#M6446</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1063032"&gt;@ayushaggarw&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I hope you are doing well . Does your query is resolved ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If my response helps you then mark it as helpful and accept as solution .&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aditya,&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2026 03:59:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3512456#M6446</guid>
      <dc:creator>Aditya_hublikar</dc:creator>
      <dc:date>2026-03-23T03:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use GlideAjax?</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3516504#M6500</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/1063032"&gt;@ayushaggarw&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;if the above solution is helpful for you please mark it as helpful and accept the solution to close the thread.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Sagnic&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2026 15:14:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-to-use-glideajax/m-p/3516504#M6500</guid>
      <dc:creator>Its_Sagnic</dc:creator>
      <dc:date>2026-03-29T15:14:25Z</dc:date>
    </item>
  </channel>
</rss>

