Accessing global script include from client side scoped application error

sohailsarwar
Tera Contributor

Hi, I have created  a global scoped application with a Script Include as shown in the screenshot. I tried to call this script include from onsubmit client script of another scoped application (see script pasted below) but the platform generates error " When targeting a global resource, only ServiceNow authored scopes are allowed as sources ".  Does it mean, I can't call script includes from a global scoped application that I have created? I did create a record in "Application cross-scope access" table to allow execution of script include from scope application. Sorry, I am new to ServiceNow and learning at the moment.

 

sohailsarwar_0-1762649114296.png

 

function onSubmit() {
  
     var getEmailAddr = new GlideAjax('global.UtilsString');  
    getEmailAddr.addParam('sysparm_name','validateEmailAddress');  
    getEmailAddr.addParam('sysparm_emailstr',       g_form.getValue('u_requested_for_email'));
    // Send the request to the server
    getEmailAddr.getXML(populateEmailField);
 
 
    // When the response is back from the server
    function populateEmailField(response){
       
        var isValid = response.responseXML.documentElement.getAttribute("answer");
alert(isValid);
        
    }
 // return confirm('Please confirm to proceed with your new record');
 
}
2 REPLIES 2

lpruit2
Kilo Sage

Greetings @sohailsarwar,

 

I believe you have a mismatch in scopes within your Script Include between your Application field and the API name. The expected syntax of the API name is listed below. Your Script Include is showing that it is in the "CustomUtils" application scope, however, your API name shows "global.UtilsString".  

 

<application_scope_prefix>.<script_include_name>

 

Can you click the preview icon to the immediate right of the Application field and look for the Scope value. It will be in some sort of format with underscores instead of spaces. I'll include a link to Script Includes from ServiceNow documentation. I hope this helps! 

Script includes

Hi @lpruit2 

                      Thanks for your reply. The scope is global as shown in the screenshot below.

sohailsarwar_0-1762731732921.png

sohailsarwar_1-1762731733065.png