Previous actions: Create an Script Include and check .
Script Include { "Client Callable"= true }
var scriptIncludeName = Class.create();
scriptIncludeName.prototype=Object.extendsObject(AbstractAjaxProcessor, {
methodName: function() {
//your code
//how to Call another method in same class
this.methodName2();
//how to Call method in differentClass(another script include)
var a = new differentClass();
a.otherMethodName();
return '';
},
methodName2: function () {
var obj = {};
obj.username = gs.getUserName();
return JSON.stringify(obj);
},
type: 'scriptIncludeName'
});
Client Script:function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { return; } if (newValue != undefined) { var list = g_form.getValue("u_category"); var ga = new GlideAjax('
scriptIncludeName
'); ga.addParam('sysparm_name', 'methodName
'); ga.addParam('sysparm_list', list); ga.getXML(showITfieldsOnload); } else { //do something } }function showITfieldsOnload(response) { var answer= response.responseXML.documentElement.getAttribute("answer"); if (answer==true || answer.toString().toLowerCase()== 'true') { //do something id it's true } else { //do something if it's false } }