You are on page 1of 2

Script Include

Script Includes are reusable server-side JavaScript functions. They are


Server side scripts that can be called by another server script like BR or
a client side script like CS, but to call a script include from client side;
Client Callable check box should be check while defining the SI
Consider using script includes instead of global business rules because
script includes are only loaded on request.
To define a SI navigate to System Definitions > Script Includes
Script includes have a name, description and script. They also specify
whether they are active or not, and whether they can be called from a
Client Script
Syntax to write a SI is below:
var NewInclude = Class.create();
NewInclude.prototype = {
initialize : function() {
},
myFunction : function() {
//Put function code here
},
type : 'NewInclude'
};

Syntax to call a SI from client script is below:


var ga = new GlideAjax('HelloWorld');
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);
}
(Note: It is an Async call and if you use:

Glide Ajax call)

ga.getXMLWait(); then it a Synchronous

Syntax to call a SI from BR is below:

var foo = new NewInclude();


foo.myFunction();

(Note: SI is a reusable server side script and there is UI Script which is a clientside reusable script)

You might also like