cancel ui action

twenger26
Giga Contributor

I am trying to add a UI Action button called "Cancel" on a new form (insert).   I've tried this code below in the UI Action, but when the user clicks the button it still requires the user to fill in mandatory fields.   I want the user to be able to just cancel the new record and go to another page.   I've tried using "return false;" in the UI Action, but that code isn't allowed for some reason.   Does someone know a way to abort a form submission by not using an onSubmit client script, but rather a UI Action?

current.setAbortAction(true);

var url = 'https://phcitest.service-now.com/u_finance_employee_expense_line.do?sys_id=-1&sysparm_query=u_employee_expense_request=' + current.u_employee_expense_request.sys_id.toString();

gs.setRedirect(url);
1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

I think you'll want to change this to run as a client-side UI action instead.  Simply replace your URL in the function shown below.  Also note that you don't need your instance prefix...just everything after the slash.  Also make sure if you're on a London or later instance that the 'Isolate script' checkbox (which you may need to add to the form) is unchecked.

find_real_file.png

View solution in original post

2 REPLIES 2

Mark Stanger
Giga Sage

I think you'll want to change this to run as a client-side UI action instead.  Simply replace your URL in the function shown below.  Also note that you don't need your instance prefix...just everything after the slash.  Also make sure if you're on a London or later instance that the 'Isolate script' checkbox (which you may need to add to the form) is unchecked.

find_real_file.png