Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Open URL onclick ui action button

XYD23
Tera Contributor

Requirement is:
When I click on the Ui action button on a form,
a URL should open in a new tab of that particular browser.

1 ACCEPTED SOLUTION

Anand Kumar P
Giga Patron

Hi @XYD23 ,
i have tried working fine in my pdi.

AnandKumarP_1-1701678043149.png

 

AnandKumarP_0-1701678005544.png

function exportPDF() { 
 
 var instanceName='https://www.w3schools.com/';
 g_navigation.openPopup(instanceName);
} 

Please mark it as solution proposed and helpful if it serves your purpose.

Thanks,

Anand
 

View solution in original post

7 REPLIES 7

Anand Kumar P
Giga Patron

Hi @XYD23 ,

You can refer below link,

g_navigation.openPopup(url);


https://www.servicenow.com/community/developer-forum/how-can-i-write-this-ui-action-so-that-the-url-... 
Thanks,

Anand

Amit Gujarathi
Giga Sage
Giga Sage

HI @XYD23 ,
I trust you are doing great.
In the "Script" section of the UI Action, you will write JavaScript to open the desired URL in a new tab. Here's a sample script:

function openURL() {
    var url = "https://www.example.com"; // Replace with your desired URL
    window.open(url, '_blank');
}

if (typeof window == 'undefined') {
    openURL();
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



I tried this, but not working,
if possible can you send me screenshots.

 

Hi @XYD23 

 

Please make sure the Client checkbox is checked.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.