UI Action to redirect from one table to another

vibee
Kilo Expert

Hi, I would like some assistance in creating a UI Action on a custom table I created.

This button needs to save the form on table 1, and then redirect the user to a second/table form.

How would I script/build this?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Vibee,



Your script will contain two basic components.



current.update(); // save the current record (from table 1)


action.setRedirectURL(url_to_table_2_record);



The details of that url_to_table_2_record are up to you. It can either be a GlideRecord or a string. For example, if you have a GlideRecord for your other table...


var t2 = new GlideRecord('u_table2');


t2.get(current.u_reference_field_to_table2);


action.setRedirectURL(t2);



The above could also be done like this:


action.setRedirectURL('u_table_2.do?sys_id=' + current.u_reference_field_to_table2);



Or if you want to create a new record on table2, it might look like this:


action.setRedirectURL('u_table2.do?sys_id=-1');



That should give you some ideas. 🙂


View solution in original post

10 REPLIES 10

Pradeep Sharma
ServiceNow Employee

Hi Vibee,



Please refer below thread and adjust your solution. Let me know if you are blocked.


Client & Server Code in One UI Action - ServiceNow Guru



For reference you can refer UI action "Create Change" on incident form which redirects to change request using action.setRedirectURL


UI Actions - ServiceNow Wiki


Chuck Tomasi
Tera Patron

Hi Vibee,



Your script will contain two basic components.



current.update(); // save the current record (from table 1)


action.setRedirectURL(url_to_table_2_record);



The details of that url_to_table_2_record are up to you. It can either be a GlideRecord or a string. For example, if you have a GlideRecord for your other table...


var t2 = new GlideRecord('u_table2');


t2.get(current.u_reference_field_to_table2);


action.setRedirectURL(t2);



The above could also be done like this:


action.setRedirectURL('u_table_2.do?sys_id=' + current.u_reference_field_to_table2);



Or if you want to create a new record on table2, it might look like this:


action.setRedirectURL('u_table2.do?sys_id=-1');



That should give you some ideas. 🙂


I am trying the reDirect, but i'm not sure where I can pull the table name for the Order Guide. I would like it to redirect to a new Order Guide page.



would it be action.setRedirectURL(https://is/com.glideapp.servicecatalog_cat_item_guide_view.do?v=1&sysparm_initial=true&sysparm_guide... );