i am not getting any alerts on glide ajax

Community Alums
Not applicable

Hi,

Can you please let me know why my alert is not getting triggered?

 

ajax.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
	alert("inside ajx");
	var get_Caller_Details = g_form.getValue("caller_id");
	var ga = new GlideAjax("multiple_Autopopulate_Class");
	ga.addParam("sysparm_name","multiple_Autopopulate_Function" );
	ga.addParam("sysparm_id", get_Caller_Details);
	ga.getXML(callBackFunction);
	function callBackFunction(response){
   var answer = response.responseXML.documentElement.getAttribute("answer"); 
   alert("response is " + response);
   alert("answer is " + answer);
	}


}

 

Script.png

 

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

    multiple_Autopopulate_Function: function() {
        var parm = this.getParameter("sysparm_id");
        var gr = new GlideRecord("sys_user");
        gr.addQuery("sys_id", parm);
        gr.query();
        if (gr.next()) {
			return gr.email + ", " + gr.location + ", " + gr.manager;
        }

    },

    type: 'multiple_Autopopulate_Class'
});

 

Regards

Suman P.

17 REPLIES 17

Jaspal Singh
Mega Patron
Mega Patron

Which alert particularly is not triggered? Also, I see the script is onChange(). Hope you are checking post change of Caller field.

Community Alums
Not applicable

Hi @Jaspal Singh ,

I am changing the caller field, but the alert is not triggered. Inside Ajax

Hello @Community Alums 

 

Instead of alert(), Use gs.log();

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Community Alums
Not applicable

I am using the alert on the client-side right.

Community Alums
Not applicable

You should be able to see at least the 1st alert() message.
Also, open your browser console and check for errors.

Additionally - not sure why you use Pascal case for naming, but it would be better to use CamelCase. For script includes - should start with capital letter - MultipleAutoPopulateClass (best skip Class if you ask me). For methods in the SI - multipleAutoPopulateFunction (I'd remove the function from the name also. USe some verb instead - multipleAutoPopulSet or smtn).