In how many methods we can call script include in client scripts??

jaiku
Giga Contributor
  1. 1. In how many methods we can call script include in client scripts
8 REPLIES 8

Shishir Srivast
Mega Sage

Hi Jai,



Are you looking to know how many times can we call script include methods in client script using GlideAjax, if yes then i think using GlideAjax we can call multiple methods or we can do multiple GlideAjax (not sure about the count, should be no limit ) with Asynchronous GlideAjax call using getXML() function. As per my understanding script include is a set of reusable methods which can be used/call multiple times. For example i just tried this without any issue.



function onLoad() {


var ajax = new GlideAjax('MyDateTimeAjax');


ajax.addParam('sysparm_name', 'firstfunction');


ajax.getXML(ajaxResponse);


function ajaxResponse(serverResponse) {


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


alert(answer);


}


ajax.addParam('sysparm_name', 'secondfunction');


ajax.getXML(ajaxResponse1);


function ajaxResponse1(serverResponse) {


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


alert(answer);


}



Script Include:


var MyDateTimeAjax = Class.create();


MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {


firstfunction : function () {


return 'Hello First Method';


},


secondfunction: function () {


return 'Hello Second Method';


},


}



Let us know if you are looking anything specific?


What are methods used in Risk calculation UI action


Calculate Risk UI Action just call one method setRisk from SetChangeRisk Script Include.


Hello,  @Shishir Srivast I tried your script but its calls a second function onload of the form. It's not working for the first function. can you please guide me on this?

Thank You.