Adding an Auto Sequential Field to your Maintenance Application
Click here to access the legacy version of this documentation.
There will be many times when, on any data entry screen, you will want your key field to automatically query the database to see what the last number being used was and increase that by one. Using an Auto Sequential field will eliminate your end users from having to select their own key field, and it will also eliminate the need for you to create an external object that would accomplish this.
In the documentation below, we will create an Auto Sequence field for our New Order Entry screen.
Select the appropriate file and fields. In our case we will select Order #, Customer #, Order Date, Ship Date. We will also sequence by Customer Number.
Now that our fields are selected, go to dimensions. When selecting Order # as a dimension, be sure to click the "Auto Sequence" check mark.
Note: Since this field will be written to the database, the "Field Type" must be set to "Update". In addition, this field must be a numeric sequence key to utilize the auto-sequence functionality.
Build/Compile your application.
At run time, we are shown this screen:
The last record in the file for Customer Number was 102061, so our application received the next one available 102062.
Common question — How do I remove the Autosequence row from displaying on the page? My users don't need to see this number.
You could remove the text via m-Painter, however it would make more sense to hide the entire row from view. More often than not, if you do not wish your end user to type in their own key field, you probably do not want them to see it in general. The below process will explain how to hide the row.
- Open m-Painter for your application.
- Right-click on the row you wish to hide, and click "Hide row".
While you do not see the row hidden, at run time it will not be visible. After saving the application, my screen now shows:
While we cannot see the Auto Sequenced number, it is still within the HTML and ready to be submitted to the database as soon as the user clicks the "Accept" button.