One often needs to keep a counter to provide for example a document number. One way to add a counter to a table is shown below.
It is a two step process. First create a button to increase a counter in the table tabCounterSalesInv by one. Create a second button, that will add a new row to the table with the counter. Finally, in the table that you want to have a serial number create a button that will push the aforementioned two button in sequence. (This was before I learned about the runactions() formula ....)
Please see an example implemented below,
The blue buttons and the counter table can be hidden from the user views.
Increase Sales Invoice Nr