open a new form from ui action

ggg
Giga Guru

I want to open a new form for a table and prepopulate some of the values on that form when it opens.

I want to do this from a ui action.

I have the correct url - if i paste my url into my browser the form opens on the correct table with the description field prepopulated correctly.

i have a client script, show on update, client is checked, onClick is createMyNewRecord(), script is

function createMyNewRecord(){

    var url = 'my url';

     i realize that  action.setRedirectURL(url); is for server side.

    how do i get the form to open in a new window from this client script???

}

1 ACCEPTED SOLUTION

The SN Nerd
Giga Sage
Giga Sage

The correct API to use is GlideNavigationV3

g_navigation.open(url, target); //Redirects to a new URL.
g_navigation.openPopup(url, name, features, noStack); //Opens a popup window.
g_navigation.openRecord(tableName, sys_id); //Redirects to a record. The record will be displayed in the navigator.

Where ServiceNow API exists it should be used in place of native JS functions.

 

 

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

3 REPLIES 3

Ragini Kukade
Kilo Guru

Hi, for client side you can use window.open or window.location to redirect to particular form.

var sysId = g_form.getUniqueValue();

var url = '/<tableName>.do?sys_id=' + sysId;

window.open('url');//Form will open in new window

OR

you can use

window.location="your url";//form will open in same window

Mark Correct /helpful,if it helps.

Regards,

Ragini

The SN Nerd
Giga Sage
Giga Sage

The correct API to use is GlideNavigationV3

g_navigation.open(url, target); //Redirects to a new URL.
g_navigation.openPopup(url, name, features, noStack); //Opens a popup window.
g_navigation.openRecord(tableName, sys_id); //Redirects to a record. The record will be displayed in the navigator.

Where ServiceNow API exists it should be used in place of native JS functions.

 

 

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

SHIVAM JAISWAL
Tera Contributor

Hi,

You can directly use gs.setRedirect('url'); without giving any action name or function name and without checking client checkbox. action.setRedirectURL('url'); was not working for me but gs.setRedirect('url'); did work.

Please mark correct/helpful if it works for you..

 

Regards,

Shivam