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

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Rahul Sharma wrote:



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 ?


Yes, it is.   The question is... what do you want to do with it once "opened"...? You're basically connecting to a web page but unable to display the content (it's running in the background).



Are you after parsing the content then doing something with it?


Thanks Dave for the reply.


Actually I wanted to download an attachment. Is there a way to hit a URL from the background script.




Thanks with regards.


Actually I wanted to download an attachment. Is there a way to hit a URL from the background script.


Yes - there will be various ways to obtain content held remotely.



However, are you going to parse this attachment in any way?   It sounds like Import Sets may be the thing you're after - but you've not really described your problem, just help with your considered solution.


sachin_namjoshi
Kilo Patron
Kilo Patron

You can open URL via script include.


Please see example below.



var url = 'https://www.google.com/';


gs.setRedirect(url);



GlideSystem - ServiceNow Wiki



Regards,


Sachin