Call Ajax Script Include from Client Script

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
      }
}

Deja una respuesta 0

Your email address will not be published. Required fields are marked *

Este sitio esta protegido por reCAPTCHA y laPolítica de privacidady losTérminos del servicio de Googlese aplican.

El periodo de verificación de reCAPTCHA ha caducado. Por favor, recarga la página.