UI Scripts not injected in some pages

rmalhotra
Tera Contributor

Hi,

I created a simple UI Script which is supposed to attach listener on window object. I marked this script as Active and Global.

But in some instances of ServiceNow this script is not injected into pages. By injection I mean that this script is not available at all.

uiscript.PNG

I tried looking up browser source and came to know that all scripts are combined into one js_includes_customer*.js and then injected into page via which all UI Script are made available. So basically no script is included. I have already checked for javascript syntax / errors.

UIScript2.PNG

Any clue?

1 ACCEPTED SOLUTION

venkatiyer1
Giga Guru

Hi Rahul,



Global UI scripts run within the gsft_main iframe. So if you are trying to access between frames you might have to accordingly adjust your logic to attach event listeners and publishers to other frames. Please add more detail as to what you are trying to accomplish here.


View solution in original post

4 REPLIES 4

lorisd_avanzo
ServiceNow Employee
ServiceNow Employee

Hi Rahul,



What do you mean by saying 'in some instances'.


Please if you share some more indications in order to let me check a possible reason of that behavior.


In particular, which are the pages where the javascript is not included.



Regards,


Loris D'Avanzo


I have multiple instances of ServiceNow, its not available on dashboard pages and randomly on list pages.


venkatiyer1
Giga Guru

Hi Rahul,



Global UI scripts run within the gsft_main iframe. So if you are trying to access between frames you might have to accordingly adjust your logic to attach event listeners and publishers to other frames. Please add more detail as to what you are trying to accomplish here.


Because ServiceNow's plugin "OpenFrame" doesn't provide any API to interact directly with ServiceNow's other components like UI Scripts Etc. We are trying to develop a communication API between two using browsers PostMessage technique. But Randomly it fails as UI Script doesn't get included on some of the pages.