This PHPMaker 2024 project will show you how to get next code with our-defined-format (J00001, J00002, J00003, and so forth), while adding a new record into a table. Besides for Add Page, it's also working for Grid-Add mode.
As you can see, the prefix is J, and the last five characters are sequential number with Zero (0) character before the actual number value. This is very useful, so that our Code length are the same for all records.
Basically, we only need three Server Events for this. The first one is Global Code, the second one is Row_Rendered, and the third one is Row_Inserting.
The most interesting part is, we can implement this for Grid-Add mode, too. We just need additional code in Page_Load server event that belongs to the List Page for this.
In addition, this logic is also working properly for Copy Page. When end-users are trying to copy from the existing record, then the value in Code field will automatically be adjusted to the next latest one.
From this project, then we will also learn how to prevent end-users removing the records. We just need to write a few lines of code in Row_Deleting server event.
That's it! How easy and fast we can do all of this via PHPMaker 2024 project!