Unable to call the script include in scoped app

Rakesh50
Mega Sage

Hi,

 

We have 'nums' script include and it has few table sys_id's so which we used whenever it required. We have scoped application and' nums' SI also in same scope. We also have 'practice' reference field and it has 3 records and we stored this sys_id's in 'nums' SI. Now we have a requirement that if 'practice' field is 'service' we have to populate some fields.

for that i tried below script but that is throwing this below error.

onChange script error: ReferenceError: nums is not defined function () { [native code] }

 

 

 

ClientScript:- 
if(newValue.length > 0) {
		var isServices = newValue == nums.practice.Services;
		alert(isServices);
   g_form.setDisplay('requested', true);
}
Script Include:-
 var nums = {
  
    country : {
        other: "661fdeaddbb8c0106982e2e3ca9619d2"
    },
    practice: {            
        Services: "da56ad1f474ae11060475a37e26d43c8",                  
        Security: "9e60b9c5970a2d504dc2f5efe153af4b",         
        Social: "2abddab1871969103208113e3fbb3537",
    },
};

 

 

@AnveshKumar M 

 

10 REPLIES 10

Try using the full namespace for the script include. For example, if the script include is scoped to "x_app" and the name is "nums", you would use "x_app.nums" to reference it in your code.

 

Hi @Ratnakar7 

yes I have added my scoped app name but it is showing below error

onChange script error: ReferenceError: "x_app" is not defined function () { [native code] }

Ankur Bawiskar
Tera Patron
Tera Patron

@Rakesh50 

can you share your complete script include and client script along with script screenshots.

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

Hi @Ankur Bawiskar 

 

The script include has 400 lines of code and it has with company info. so i can't share. But I can tell if you need any clarifications on this.

@Rakesh50 

please don't share in that case.

I would suggest you to debug by adding gs.info() statements as that will help you.

Things to check

1) is script include getting called check by adding gs.info()

2) add alert in client script to check script is working till which line

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