Error: Access to Script Include CepIntegrationAjax blocked from scope: x_1487170_a_a_no_0

Otavio_Jordao
Tera Contributor

Hello,
I would like help.

I'm creating a record producer with a field that automatically takes the zip code.

 

However, I am facing the following error:

Access to Script Include CepIntegrationAjax blocked from scope: x_1487170_a_a_no_0

 

this is my script include:

var CepIAjax = Class.create();
CepAjax.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    _realizarRequisicao: function() {
        var baseUrl = 'https://opencep.com/v1/';
        var cep = this.getParameter('sysparm_cep');

        var request = new sn_ws.RESTMessageV2();
        request.setHttpMethod('get');
        request.setEndpoint(baseUrl + cep + '/json');
        var response = request.execute();
        var httpResponseStatus = response.getStatusCode();
        var body = JSON.parse(response.getBody());

        return {
            httpResponseStatus: httpResponseStatus,
            body: body
        };
    },
    fetchStreet: function() {
        var resposta = this._realizarRequisicao();

        if (resposta.httpResponseStatus == 200) {
            return resposta.body.logradouro;
        }

    },
    fetchNeighborhood: function() {
        var resposta = this._realizarRequisicao();

        if (resposta.httpResponseStatus == 200) {
            return resposta.body.bairro;
        }
    },
    fetchCity: function() {
        var resposta = this._realizarRequisicao();

        if (resposta.httpResponseStatus == 200) {
            return resposta.body.localidade;
        }
    },
    fetchState: function() {
        var resposta = this._realizarRequisicao();

        if (resposta.httpResponseStatus == 200) {
            return resposta.body.uf;
        }
    },
    fetchComplement: function() {
        var resposta = this._realizarRequisicao();

        if (resposta.httpResponseStatus == 200) {
            return resposta.body.complemento;
        }
    },
    type: 'CepAjax'
});

This my catalog client script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    informationAddress('fetchStreet', 'cep');
    informationAddress('fetchStreet', 'logradouro');
    informationAddress('fetchNeighborhood', 'bairro');
    informationAddress('fetchCity', 'cidade');
    informationAddress('fetchState', 'estado');
    informationAddress('fetchComplement', 'complemento');


    function informationAddress(metodo, variavel) {
        var gaRua = new GlideAjax('CepIntegrationAjax');
        gaRua.addParam('sysparm_name', metodo);
        gaRua.addParam('sysparm_cep', newValue);
        gaRua.getXML(callback);

        function callback(response) {
            var answer = response.responseXML.documentElement.getAttribute("answer");

            if (answer) {
                g_form.setValue(variavel, answer);
           
            } else {
                    var valorCep = g_form.setValue('cep');
                if(valorCep !=''){
                    g_form.clearValue('complemento');
                    g_form.clearValue('check');
                    g_form.clearValue('cep');
                }
                   
                }
        }
    }
}

 

1 ACCEPTED SOLUTION

Vrushali  Kolte
Mega Sage

Hello @Otavio_Jordao ,

 

This typically occurs when you try to access a Script Include that is not accessible from the current application scope.

Set the Accessible from field to All application scopes as below -

VrushaliKolte_0-1723039845747.png

 

If setting the Accessible from field to All application scopes doesn't resolve the issue, you may need to create a cross-scope privilege. Please refer below document -

 

https://docs.servicenow.com/bundle/washingtondc-application-development/page/build/applications/refe...

 

If my answer solves your issue, please mark it as Accepted ✔️& Helpful!👍

 

 

View solution in original post

3 REPLIES 3

Neeraj31
Mega Sage

Hello,

Check if your script include was set to be accessible from other scopes. Please check your script include settings.

 

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Bert_c1
Kilo Patron

Vrushali  Kolte
Mega Sage

Hello @Otavio_Jordao ,

 

This typically occurs when you try to access a Script Include that is not accessible from the current application scope.

Set the Accessible from field to All application scopes as below -

VrushaliKolte_0-1723039845747.png

 

If setting the Accessible from field to All application scopes doesn't resolve the issue, you may need to create a cross-scope privilege. Please refer below document -

 

https://docs.servicenow.com/bundle/washingtondc-application-development/page/build/applications/refe...

 

If my answer solves your issue, please mark it as Accepted ✔️& Helpful!👍