Well the use case is pretty simple, I would like to include a monitoring framework such as Dynatrace into my ServiceNow instance. It works ok with a global ui script, but it is stuck in the page iFrame which is not the perfect solution.


Hi Chuck,



Any ideas on that?



Thanks,


Wolfgang


No ideas at this time. Perhaps someone else in the community can jump in.


ChrisBurks
Giga Sage

If you place something like below in a UI script and make that global should work.



(function(){


  var top = getTopWindow().window.document.querySelector('head');   // reach out to the parent window and get the head element


  var script = document.createElement('script');   //create a new script element


  script.src = 'path/to/js/library';   //sets the src attribute


  script.type = 'text/javascript';   //sets the type attribute


  top.appendChild(script);     // appends the newly created script element at the end of the top window head element


})();


topWindow.png


View solution in original post

Hi ChrisB,

I tried to use the function but I get 'Uncaught ReferenceError: getTopWindow is not defined' error. Am I doing something wrong? I am on Kingston patch 4.

 

var top = getTopWindow().window.document.querySelector('head');   // reach out to the parent window and get the head element