Getting Cross Scope Error even after granting Cross Scope Privileges

Aniket Bhanse
Tera Guru

I am trying to create a simple script include from Fix script (Scoped Application) in the global application (The script include should be created in the global application) and I am getting the error Cross Scope Error. And I have granted the Cross Scope already of Create, Write and Read and Execute API as well. But still the error is there. 

var SIGr = new GlideRecord('sys_script_include');
SIGr.initialize();

SIGr.name = 'MyNewScriptInclude';
SIGr.api_name = 'global.MyNewScriptInclude'; 
SIGr.script = `
var MyNewScriptInclude = Class.create();
MyNewScriptInclude.prototype = {
    initialize: function() {
    },

    myFunction: function() {
        // Your script logic here
        return 'Hello from MyNewScriptInclude!';
    },

    type: 'MyNewScriptInclude'
};
`;
SIGr.client_callable = true;
SIGr.active = true;
SIGr.description = 'This is a sample script include.';
SIGr.sys_scope = "global";
var sysId = SIGr.insert();

if (sysId) {
    gs.info("Script Include created with sys_id: " + sysId);
} else {
    gs.error("Failed to create Script Include. Check for existing sys_id or name conflicts.");
}

 

Please suggest what should I do.

Thank you

18 REPLIES 18

I cannot use single quotes ' ' as well

Ankur Bawiskar
Tera Patron
Tera Patron

@Aniket Bhanse 

but why to create script include from fix script?

I never came across any such requirement in my past experiences.

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

I have an eBonding Integration, so that when a button is clicked, all the script includes related to that catalog item will be moved from one instance to another. So my logic is in the UI Action's script. 
But since it was not creating a script include in the Target instance, therefore I am first trying to execute it using Fix Script. 

Aniket Bhanse
Tera Guru

@Ankur Bawiskar @GlideFather 

I have declared the cross scope previleges as well
Screenshot 2025-06-17 160313.jpg

These are the cross scopes that I have created. Along with this, there is one more which is for "Read" operation. That was by default.

@Aniket Bhanse 

Still I will recommend not to do this via script.

You can always migrate script includes via update set between 2 instances, why to use API for that?

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