Unable to call the script include in scoped app
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2023 09:07 PM - edited 04-28-2023 07:17 AM
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",
},
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 08:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 08:28 AM
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] }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 07:31 AM
can you share your complete script include and client script along with script screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 07:57 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 07:59 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader