How to Open a URL from Background Script

rahul_sharma
Kilo Contributor

Hi Everyone,

Can I open a URL from background script or script include. For example I want to open www.google.com in a new tab from background script. Is it

possible ?. I know its possible from Client script but I have a certain requirement in which I have to open the URL from backgdoun script

( script include). Thanks in advance everyone.

Thanks with regards,

Rahul Sharma

7 REPLIES 7

Thanks Sachin for the reply.


I tried gs.setRedirect(url) in the background but it didn't worked




Thanks with regards.


Shiraz2
Mega Guru

Rahul, let's make one thing clear, there is a huge difference between Background Script and Script Include. They both uses Java, they are two different beasts; functionality wise. Although they both are powerful, Background Script can do some serious damage if proper precautions are not taken when authoring a script.


Please see below:



Script Includes - ServiceNow Wiki


https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/script/server-scripting/concept/...



I hope this helps.


FanchenBao
ServiceNow Employee
ServiceNow Employee

You can open URL inside the script of an UI action using the `action.setRedirectURL` API. The following example is taken from the script of the "Export to XML" UI action.

 

action.setRedirectURL("export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true&sysparm_is_remote=false&sysparm_ck=" + gs.getSessionToken());