Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Unhandled exception in GlideAJAX

Dave_p
Giga Guru

Hi,

 

I am facing a issue in GlideAJAX and ScriptIncludes. Kindly help.

 

GlideAJAX

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
	g_form.addInfoMessage("before");
    if (newValue == "") {
        g_form.setValue('current_primary_approver', "");
        g_form.setValue('share_type', "");
        g_form.setValue('protocol_type', "");
    } else {
		g_form.addInfoMessage('after');
        var ga = new GlideAjax('populate_modify_network');
        ga.addParam('sysparm_name', 'get_modify');
        ga.addParam('sysparm_share_path', newValue);
        ga.getXML(callBackFunction);
		g_form.addInfoMessage('entering function');
        function callBackFunction(response) {
			g_form.addInfoMessage('line 1');
            var answer = response.responseXML.documentElement.getAttribute("answer");
			g_form.addInfoMessage('line 2');
            var op = JSON.parse(answer);
			g_form.addInfoMessage('line 3');
            g_form.setValue('current_primary_approver', op.approver);
			g_form.addInfoMessage('line 4');
            g_form.setValue('share_type', op.type);
			g_form.addInfoMessage('line 5');
            g_form.setValue('protocol_type', op.protocol);
			g_form.addInfoMessage('line 6');


        }

    }
}

 

1.png

 

ScriptIncludes

 

var populate_modify_Network = Class.create();
populate_modify_Network.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	get_modify : function()
	{
		var path = this.getParameter('sysparm_share_path');
		var values = {};
		
		var gr = new GlideRecord('u_cmdb_ci_file_share');
		gr.addQuery('sys_id',path);
		gr.query();
		if(gr.next())
			{
				values.approver = gr.managed_by.toString();
				values.type = gr.u_type.getDisplayValue();
				values.protocol = gr.u_protocol.getDisplayValue();
				
				
				
				
			}
		return JSON.stringify(values);
	},

    type: 'populate_modify_Network'
});

 

2.png

 

3.png

 

Error

 

4.png

 

I am getting until 'entering function'.

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Martin Friedel
Mega Sage

Hello, you have typo in Catalog Client Script:

 

 var ga = new GlideAjax('populate_modify_network');

 

Parameter is case sensitive, it should contain capital letter N:

 

 var ga = new GlideAjax('populate_modify_Network');

 

 

If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin

View solution in original post

2 REPLIES 2

Martin Friedel
Mega Sage

Hello, you have typo in Catalog Client Script:

 

 var ga = new GlideAjax('populate_modify_network');

 

Parameter is case sensitive, it should contain capital letter N:

 

 var ga = new GlideAjax('populate_modify_Network');

 

 

If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin

Kieran Anson
Kilo Patron

Hi,

You should be able to avoid a GlideAjax call and client script altogether.

 

You can use the auto populate option on your 3 variables, and set the dependency to the share_path field. You can then choose the value to populate via the reference field. This config is done directly on each variable record

 

KieranAnson_0-1739969657023.png