Issues loading multiple UI scripts in configurable workspaces

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 07:41 PM - edited 11-17-2023 07:53 PM
I am running into some challenges trying to load multiple UI scripts (all set to UI Type ALL) in via an onLoad Client Script in a configurable workspace such as Service Operations Workspace.
Take the following onLoad Client Script set to run on Mobile / Service Portal:
function onLoad() {
g_ui_scripts.getUIScript('VariableStateChecker').then(function(script) {
console.log('!VariableStateChecker loaded');
});
g_ui_scripts.getUIScript('ServiceCatalogForm17_v2').then(function(script) {
console.log('!ServiceCatalogForm17v2 loaded');
});
g_ui_scripts.getUIScript('GlideFormUI16').then(function(script) {
console.log('!GlideFormUI16 loaded');
});
g_ui_scripts.getUIScript('GlideFormWEP').then(function(script) {
console.log('!GlideFormWEP loaded');
});
g_ui_scripts.getUIScript('FieldStateChecker').then(function(script) {
console.log('!FieldStateChecker loaded');
});
}
Sometimes all the scripts load. Sometimes none of the scripts load. Sometimes a few of the scripts load.
The error message can be seen in the console. Screenshots below of different scripts failing on different occasions.
I am using Incognito mode in Google Chrome with cache disabled. I have observed the same behaviour in other browsers, so the issue seems to be with ServiceNow.
I have tried clearing the browser cache, running cache.do, gs.invalidateCache() and updating the UI scripts to no avail. Some UI scripts i have previously created load every time with no issue. I have also tried chaining the script loads to come in one at a time and still face the same issue.
The same UI scripts load consistently in the classic interface using the ScriptLoader.getScripts API. All UI Scripts are a Self Invoking function that return the API via public functions, and work for both interfaces when they are loaded successfully.
I am facing this issue in my PDI, both in Utah and post-upgrade to Vancouver.
Are UI scripts not supported in configurable workspaces? Is there another way I should be doing this, that will work for all workspaces? I am keen to re-use my code across the relevant UI.
Thanks.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022