A commonly integrated feature in many business applications is a button to save and move to the next record in form view. This allows users to rapidly change many records.
Let’s implement a “Save and Next” action on the Orders form.
Start the Project Designer. In the Project Explorer, switch to the Controllers tab. Right-click on Orders / Actions / ag2 (Form) node, and press New Action.
![Creating a new action on the form of Orders controller. Creating a new action on the form of Orders controller.](/blog/2012/12/configuring-save-and-next-button/image02.png)
Assign the following values:
Property | Value |
Command Name | Update |
Command Argument | Next |
Header Text | Next |
When Last Command Name | Edit |
Press OK to save the action. Drop a100 – Update, Next when Edit | Next action node on the left side of a1 – Edit to place it first in the form.
![Action 'a100' placed first on the form. Action 'a100' placed first on the form.](/blog/2012/12/configuring-save-and-next-button/image06.png)
Right-click on Orders / Business Rules, and press New Business Rule.
![Creating a new business rule for Orders controller. Creating a new business rule for Orders controller.](/blog/2012/12/configuring-save-and-next-button/image08.png)
Assign these values:
Property | Value |
Type | JavaScript |
Command Name | Update |
Command Argument | Next |
Phase | After |
Script | if (this.validateInput()) {
this.preventDefault();
this.dataView()._advance(1);
}
|
Press OK to save. On the toolbar, press Browse.
Navigate to the Orders page, and start editing a record.
![Editing a record, and pressing 'Next' to save and edit the next record. Editing a record, and pressing 'Next' to save and edit the next record.](/blog/2012/12/configuring-save-and-next-button/image10.png)
Press the Next button – the record will save and the next record will be displayed.
![The next record is displayed. The next record is displayed.](/blog/2012/12/configuring-save-and-next-button/image12.png)
Return to the grid and notice that the changes have been applied.
![The changes have been applied to the order records. The changes have been applied to the order records.](/blog/2012/12/configuring-save-and-next-button/image14.png)