Script include syntax

BALAJI K R
Tera Expert

Could you please explain me with more details, what does the below code lines (Red and underlined) does.

 

var MyFavoritesAjax = Class.create();

MyFavoritesAjax.prototype = Object.extendsObject(AbstractAjaxProcessor,

 

getFavorites: function() { 

       },

type:"MyFavoritesAjax"

 });

 

Client script:

function callback(response) { 

var result = response.responseXML.getElementsByTagName("result");

 

1 ACCEPTED SOLUTION

Mehta
Kilo Sage
Kilo Sage

The above line is a class that is been extended just like we do in java which follows object oriented approach. 

<classname>.prototype = object.extendobject(extending class),{ your script 

Usually by default we extend AbstractAjaxProcessor which is used for GlideAjax.

 

For other 

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

Let us assume we have a function in Script Include :

demofunction: function () {

        var element = this.getParameter('sysparm_parameter');

return 'Hi, This is bind with answer atrribute';

}

Now in client script   -

function myCallBack(response) {

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

alert(answer); // Output   "Hi, This is bind with answer atrribute"

}

Here "response" is an XML document which contains an attribute "answer" and the value returned from the demofunction binded with the answer attribute.

So response.responseXML.documentElement.getAttribute("answer") gives us the value returned from the script include function.

 

Please Mark helpful or correct Answer , If it solves your query.

View solution in original post

3 REPLIES 3

Mehta
Kilo Sage
Kilo Sage

The above line is a class that is been extended just like we do in java which follows object oriented approach. 

<classname>.prototype = object.extendobject(extending class),{ your script 

Usually by default we extend AbstractAjaxProcessor which is used for GlideAjax.

 

For other 

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

Let us assume we have a function in Script Include :

demofunction: function () {

        var element = this.getParameter('sysparm_parameter');

return 'Hi, This is bind with answer atrribute';

}

Now in client script   -

function myCallBack(response) {

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

alert(answer); // Output   "Hi, This is bind with answer atrribute"

}

Here "response" is an XML document which contains an attribute "answer" and the value returned from the demofunction binded with the answer attribute.

So response.responseXML.documentElement.getAttribute("answer") gives us the value returned from the script include function.

 

Please Mark helpful or correct Answer , If it solves your query.

Thanks a lot , also could me explain about in type:"MyFavoritesAjax" GlideAjax

It is the property used by servicenow as a part of default syntax, as servicenow is build on java. 

Mehta_0-1687011138401.png

 

Can you please mark it as correct answer if it resolve your query .