How to open a new window using UI action javascript after clicking a button?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2015 02:35 AM
I have tried to create a UI button and want to open a new window with a url using the button.
It seems that window.open does not work and I notice that there is a function action.setRedirectURL().
Does anyone how to open a new window?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 05:34 AM
Hi Grant,
to redirect via server-side in a UI Action; please see the following example:
However; redirecting will only forward the end user to another screen in the same browser tab/window.
To redirect the end user to another screen in a new browser tab/window via a UI Action; you'll need to work client-side; please see the following example:
Kind regards,
Stijn

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 12:36 AM
Hi Calvin,
Good Day
Client : True
Onclick : showValues()
Script :
function showValues() {
var table = g_form.getTableName(); //used to build the table name portion of the URL
var record = g_form.getUniqueValue(); //used to build the unique ID portion of the URL
window.open(table + '.do?sys_id=' + record); /*to open the window in new page*/
}
If this reply helps you, please consider marking it ✅Correct, âÂ��Helpful, or ��Liking it.
Thanks,
Priyanka R
If this reply helps you, please consider marking it ✅Correct, âÂ��Helpful, or ��Liking it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 02:38 AM
Hi Priyanka,
Can u pls help me to redirect the url in the same window instead of opening in new window.
The below code will open new window tab :
window.open(table + '.do?sys_id=' + record);
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 12:07 AM
Hi Amit,
Good Day
action.setRedirectURL(new_Record);
Please refer the below link for your reference.
http://wiki.servicenow.com/index.php?title=UI_Actions#Using_a_UI_Action_to_Redirect_to_a_URL
Thanks,
Priyanka R

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 12:45 AM
Hi Amit,
Good Day
Use the URL in the following form and which helps redirect on the same tab / window.
var url = "YOUR INSTANCE NAME/sc_req_item/"+current.sys_id+"/sysparm_view=";
action.setRedirectURL(url);
Please refer the below link for your reference:-
http://wiki.servicenow.com/index.php?title=UI_Actions#Using_a_UI_Action_to_Redirect_to_a_URL
If this reply helps you, please consider marking it ✅Correct, âÂ��Helpful, or ��Liking it.
Thanks,
Priyanka R