18 views

How to extend an existing Class in a new script include

Description


How to extend an existing Script Include class either because it is protected and cannot be edited, or to keep your changes simple instead of copying the whole script.  

Solution


This is the format for extending a script.

var YourNewScript = Class.create();
YourNewScript.prototype = Object.extendsObject(ScriptYouWantToOverwrite,



//your new code in here. 
}); 

 

Here is an Example.

var MyTimeCardPortalService = Class.create();
MyTimeCardPortalService.prototype = Object.extendsObject(TimeCardPortalService, { 

}); 

Applicable Versions


ALL

Additional Information


Some example of this in the docs are:

https://docs.servicenow.com/bundle/kingston-application-development/page/script/ajax/topic/p_AJAX.html#d70118e251

https://docs.servicenow.com/bundle/kingston-hr-service-delivery/page/integrate/workday/task/t_CustomizeDataRetrievScriptInc.html

 

Article Information

Last Updated:2018-04-11 10:39:46
Published:2018-04-02