calling script include in the ui action

Praju_123
Tera Contributor

I have created a client-callable Script Include and I'm trying to call it from a client-side UI Action. However, the Script Include is not being triggered when I execute the UI Action. I'm attaching the Script Include code, UI Action code, and screenshots. Please help me fix the issue.
script include:

Praju_123_0-1756874332952.png

code:

var BotaoDeletar = Class.create();
BotaoDeletar.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    testing: function() {
        return 25;
    }, // just for testing purpose
    type: 'BotaoDeletar'
});

ui Action:
Praju_123_1-1756874385114.pngPraju_123_2-1756874402672.png

code:

function callScriptInclude() {
    var foo = new GlideAjax('x_icpa_cargo_for_0.BotaoDeletar'); // "scope"."script include name"
    foo.addParam('sysparm_name', 'testing'); // obligatory, to call the function by its name
    foo.getXMLAnswer(function(tobeused) { // "tobeused"- name a variable to catch the response
        alert('SCRIPT INCLUDE RETURN IS ' + tobeused); // alert opens a pop-up
    });
}
2 ACCEPTED SOLUTIONS

Chaitanya ILCR
Kilo Patron

Hi @Praju_123 ,

update your script include

var BotaoDeletar = Class.create();
BotaoDeletar.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	testing: function() {
        return 25;
    }, // just for testing purpose
    type: 'BotaoDeletar'
});

 

you have to use global.AbstractAjaxProcessor since it's not in global scope

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@Praju_123 

Your syntax for script include is wrong.

Since your script include is in scoped app system automatically adds global keyword

Seems you copied the script and forgot to update that

AnkurBawiskar_0-1756878400598.png

 

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

View solution in original post

3 REPLIES 3

Chaitanya ILCR
Kilo Patron

Hi @Praju_123 ,

update your script include

var BotaoDeletar = Class.create();
BotaoDeletar.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	testing: function() {
        return 25;
    }, // just for testing purpose
    type: 'BotaoDeletar'
});

 

you have to use global.AbstractAjaxProcessor since it's not in global scope

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron
Tera Patron

@Praju_123 

Your syntax for script include is wrong.

Since your script include is in scoped app system automatically adds global keyword

Seems you copied the script and forgot to update that

AnkurBawiskar_0-1756878400598.png

 

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

Bhimashankar H
Mega Sage

Hi @Praju_123 ,

 

It seems like you are calling the different script include in glideAjax.

 

In Script Include API Name it very strage like 'x_icpa_cargo_for_().YOURSCRIPTINLCUDENAME' or 0 in place or () not sure.

but in your glideAjax function you are calling 'x_icpa_cargo_for_0.YOURSCRIPTINCLUDENAME'

 

Update your script include to 

=Object.extendsObject(global.AbstractAjaxProcessor, {

 

Maybe you can check the what is short for your application scope "Cargo-Formal Claim" then copy the name in API Name from script include and add to glideAjax. Try out on bg script first. It will show if that function is getting called or not.

 

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!