Friday, November 9, 2018

Wednesday, November 7, 2018

How to Extend a Script Include


Script Includes can extend existing Script Includes to access the methods.
In below example, I will demonstrate how we can we extend an existing Script Include with a simple Script Include.
var parentSI = Class.create();
parentSI.prototype = {
    initialize: function() {
    },
 
 upperCase : function(string){
  return string.toUpperCase();
 },

    type: 'parentSI'
};
Below you can see how childSI Script Include extended parentSI
var childSI = Class.create();
//we need to use Object.extendsObject for extending an existing script include
childSI.prototype = Object.extendsObject(parentSI,{
    initialize: function() {
    },
     
 callParent : function(string)
 {
                //calling a method from extended Script Include
  return this.upperCase(string);
 },
    type: 'childSI'
});
var result = new childSI().callParent('servicenow');
gs.log(result);
Output: *** Script: SERVICENOW
Please click here to read more on extending Script Include.
Share: