Do not redirect to table view after added new record through the form

stryker129
Mega Guru

Hello guys,

I've a table and form for this table.

I would like to stay on a form (and proceed add new records to current table) right after new record has been added, but I'm redirecting to list of records of this table and I need clicked "New" button again in order to add new record.

Is there a way to prevent redirecting and staying in the same form?

Thanks.

1 ACCEPTED SOLUTION

Hi Ivan,



'Submit' button is the OOB UI Button being used globally. So I won't recommend you to modify the OOB 'Submit' UI Action.


But for your particular table you can achieve this by writing a new Business rule as of below. I have cross checked in my personal instance in the Problem task table. You must select your required table and modify the script accordingly. Please navigate to System definition-->Business rules and click on the 'New' button.



Name: Give appropriate name


Table: Provide the table name


Advance: Checked


When: After


Insert: Checked


Script:


(function executeRule(current, previous /*null when async*/) {


      var url = '/problem_task.do?sys_id=-1';   //Change the URL as per your requirement.


      gs.setRedirect(url);


})(current, previous);



I hope this helps.Please mark correct/helpful based on impact


View solution in original post

6 REPLIES 6

amlanpal
Kilo Sage

Hi Ivan,



You can use 'Save' or 'Insert and stay' also. Right click on the form header and you can find them. For more details you can refer section 3 here Configuring Forms - ServiceNow Wiki



I hope this helps.Please mark correct/helpful based on impact


@Amlan PalThanks for your input, but I need:


1. click on "Submit" button


2. New record should be added


3. Current form should be cleared in order to add new records to table.



Is there a way to do that by clicking on "Submit" button


Hi Ivan,



'Submit' button is the OOB UI Button being used globally. So I won't recommend you to modify the OOB 'Submit' UI Action.


But for your particular table you can achieve this by writing a new Business rule as of below. I have cross checked in my personal instance in the Problem task table. You must select your required table and modify the script accordingly. Please navigate to System definition-->Business rules and click on the 'New' button.



Name: Give appropriate name


Table: Provide the table name


Advance: Checked


When: After


Insert: Checked


Script:


(function executeRule(current, previous /*null when async*/) {


      var url = '/problem_task.do?sys_id=-1';   //Change the URL as per your requirement.


      gs.setRedirect(url);


})(current, previous);



I hope this helps.Please mark correct/helpful based on impact


Thanks a lot!