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.

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

Comments added.