How to override a Script Include that is a high priority file type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 02:41 AM
I would like to have an update in one of the functions of a Script Include which is SGAzureDSHelperBase.
This SI is a high priority file type which I cannot update so I searched that functions can be overriden in a new SI so I created a custom SI named NM_SGAzureDSHelperBase. As of now this is not working, can someone recommend what is the correct way to override an Script Include? Thank you.
This is the OOB SI:
This is my Custom SI:
var NM_SGAzureDSHelperBase = Class.create();
NM_SGAzureDSHelperBase.prototype = Object.extendsObject(sn_sg_azure_integ.SGAzureDSHelperBase, {
buildResourceGraphAPIQuery: function (resourceType) {
//return "Resources | where type =~ '" + resourceType + "'";
return "Resources | where type =~ '" + resourceType + "' | where id !contains 'MC_'";
},
type: 'NM_SGAzureDSHelperBase'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 02:56 AM
To override a function in a Script Include (SI) in ServiceNow, ensure the base Script Include (SGAzureDSHelperBase) is accessible and that your custom SI (NM_SGAzureDSHelperBase) extends it correctly using Object.extendsObject.
Check that the base SI is available globally and properly configured (server or client-callable). Also, ensure there are no naming conflicts, and clear any caches or reset sessions if needed, as ServiceNow can cache Script Includes.
Here’s the correct approach for overriding the function:
var NM_SGAzureDSHelperBase = Class.create();
NM_SGAzureDSHelperBase.prototype = Object.extendsObject(sn_sg_azure_integ.SGAzureDSHelperBase, {
buildResourceGraphAPIQuery: function (resourceType) {
return "Resources | where type =~ '" + resourceType + "' | where id !contains 'MC_'";
},
type: 'NM_SGAzureDSHelperBase'
});
After updating, ensure you test in the correct environment and debug if the overridden method is being called.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 03:05 AM
there are many OOB script includes which you will find which do the same i.e. extend script include
you should create the new one in same scope
what's the error?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader