Scoped Application: How to open URLs in a new tab/window?

jivanjotkaur
ServiceNow Employee
ServiceNow Employee

I am trying to open a URL in a new tab/window in the client script of a UI action. Due to it being a scoped application, window.open(url) does not work. What alternative is there for window.open in a scoped app?

1 ACCEPTED SOLUTION

jivanjotkaur
ServiceNow Employee
ServiceNow Employee

Found that there is an API called g_navigation through which we can perform some DOm related tasks, e.g. reloading the page, opening a popup etc. I couldnt find the documentation for this API though.



For my requirement, i used the following code in my client script:



g_navigation.openPopup(url);


View solution in original post

7 REPLIES 7

srinivasthelu
Tera Guru

Hi Jivan,



I do not know if there any such apis available Out of the Box to achieve window.open functionality.



I wanted to only mention, there is a way you can opt out this restriction for the scoped app if there is an absolute reason.



You need to create below property to set its value to false.



[scope-name].glide.script.block.client.globals=false



Thanks


Srini


Hi Srini,



I created the property and it worked like a charm. However, since accessing DOM is forbidden by default by platform,   i am going to look for other ways and will keep this as last resort if i am unable to find any other alternative.



Appreciate the quick response, thanks!



Jivan


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hey Jivan,



Just to add, Please go through the below blog and comment section for more info.


FujiForty - DOM: Disabled Object Model — CAVUCode


Thanks Pradeep, very helpful article



Jivan