GlideAjax and AbstractAjaxProcessor

MPD
Giga Contributor

I am attempting to call a script include from   a client script.   The script include is working in both one of my business rules and from a UI Action.   I made modifications for the script include to include the GlideAjax constructor then created the Client Script to use the AbstractAjaxProcessor.   As soon as I do this I get the error shown below.   I was sure to check the client callable checkbox.     I am working within the scope of an application and tried both options of the Accessible from field, (i.e. "All Application Scopes" and "This Application Only"), with no luck.

After attempting to troubleshoot my script I thought I would try the one from the Wiki article.   The very simple "HelloWorld" example.   I was thinking this and some of the other examples might shed light on where I went wrong.   Low and behold I get the same error and a null message for my response.   I am attempting this in a Fulji instance in an onChange client script. At one point I even copied and pasted the code "as is" from the Wiki and tried that, but unfortunately it too returned this error.   Below is the code I am currently attempting to get working.   Does anyone have a clue as to what the issue might be ? ... this is as simple as it gets.

find_real_file.png

Client Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (isLoading || newValue == '') {

  return;

}

var ga = new GlideAjax('ATest'); // I believe this should define the processor from the script include

ga.addParam('sysparm_name','helloWorld');

ga.addParam('sysparm_user_name',"Bob");

ga.getXML(HelloWorldParse);

function HelloWorldParse(response) {

  var answer = response.responseXML.documentElement.getAttribute("answer");

  alert(answer);

}

}

Script Include:

var ATest = Class.create();

ATest.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    helloWorld: function() {

          return "Hello " + this.getParameter('sysparm_user_name') + "!";

    },

type: "ATest"

});

1 ACCEPTED SOLUTION

sidarth
Giga Expert

Hi Michael D'Amico


A slight change in your script include.



When you are writing script include in application scope please include global.AbstractAjaxProcessor



var ATest = Class.create();


ATest.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {


    helloWorld: function() {


          return "Hello " + this.getParameter('sysparm_user_name') + "!";


    },


type: "ATest"


});



Let me know if it was helpful


View solution in original post

17 REPLIES 17

sidarth
Giga Expert

Hi Michael D'Amico


A slight change in your script include.



When you are writing script include in application scope please include global.AbstractAjaxProcessor



var ATest = Class.create();


ATest.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {


    helloWorld: function() {


          return "Hello " + this.getParameter('sysparm_user_name') + "!";


    },


type: "ATest"


});



Let me know if it was helpful


MPD
Giga Contributor

Thanks ... that did the trick.



I had manually created the construct for the class in the script include following some documentation. This also helps to clarify the error message but is a bit contradictory when it comes to the documentation. There is a Wiki that indicates the scope of the application is needed and suggests that global is in reference to the global scope. In reality this really should be part of the construct regardless of scope, and in addition to that, the "Access From" field setting and access controls on the application form will ultimately determine if the script include is actually accessible. Overall the documentation for this product is fantastic but I found this to be a bit confusing.



Thanks to all who assisted ... well appreciated !


Hi Michael D'Amico


If my solution solved your problem please mark it as correct answer.


Thank You


s_kumar
Mega Contributor

HI Sidarth...



i am using global.AbstractAjaxProcessor   then also its giving same error...



can you please help me in this..


my script include..



var counttest = Class.create();


counttest.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {


      counttest: function() {


              vgs.log ('AAAA:This script is executing');


              var gr = new GlideRecord('incident');


              gr.query();


              if(gr.next())


                      { //Added this one


              var datedif = gs.dateDiff(gr.sys_created_on,gs.nowDateTime(), false);


              gs.log('AAAA:'+datedif);


              return datedif;


      }


},


type: 'counttest'


});


I tried the same thing in my instance and I did not get any error.