Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

sample example for script include call from client script

praveenraj
Tera Contributor

Hi i am new to service now i want to use script include in client script please help me.

7 REPLIES 7

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Praveen,



Please go through the example in the below link.


GlideAjax - ServiceNow Wiki


Hi Pradeep,

 

i need some examples of Script include without using return.

 

1.how can i call both server side Script Include and Client side include on Client Script (server side code and client callable code at client script).

2. I need atleast One example of both client callable Script include and Server side Script include.  

Ashish Kumar Ag
Kilo Guru

Hi,


Its almost the same in WIKI.



Create a client script and add the below code. when the client script will run user ID will be alerted.



var ga = new GlideAjax('UserID');


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


ga.getXML(myid);



function myid(response) {


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


    alert(answer);


}




Create a Scrite include with name UserID and check true client.



add the below code.



var UserID = Class.create();


UserID.prototype = Object.extendsObject(AbstractAjaxProcessor, {


    loginuser: function() {


          return gs.getUserID();


    },    


});


Hi,

Can you please explain the below line of code mentioned in Client Script.

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

Thanks,

Kuchi