The CreatorCon Call for Content is officially open! Get started here.

How to override a Script Include that is a high priority file type.

paultenorio
Tera Expert

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: 

paultenorio_0-1736419252303.png

 

This is my Custom SI:

paultenorio_1-1736419275610.png

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'
});

 

2 REPLIES 2

yuvarajkate
Giga Guru

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.

Ankur Bawiskar
Tera Patron
Tera Patron

@paultenorio 

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

Extend a Script Include 

what's the error?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader