How do you have an add form that auto increme...

How do you have an add form that auto increment the primary key? For a simple table (ID, FirstName, LastName) I want to have when you click the add button it has the ID field autofilled with the current max id + 1. Is that possible with appsheet?

0 6 417
6 REPLIES 6

Hi @Quy_Nguyen You can use MAX expression, ,only under some specific app usage conditions.The expression can be something like

MAX(TableName[ID])+1

However, please note that AppSheet typically does not recommend a sequential key generation as mentioned in

attached article.

You may implement

a sequential key only if your app has only one user or if it is a multi-user app,

then

any two users are never

likely to add a record simultaneously or the app is not going to be used in offline environment for adding records.

help.appsheet.com - Sequential Keys Sequential Keys help.appsheet.com

I would not recommend this if your app has more than one user. The duplicate value can happen even if those two users are not using the app in a same time. It’s not a timing issue, it’s a syncing issue. If the other user hasn’t used (synced) the app for example within last two days, this duplicate key will happen.

I would recommend using this expression [_Rownumber]-1…

I Understand why it would be a problem to add sequential keys if we have multiple users and if they both try to add events simultaneously. But can we somehow use “wait for a condition” OR “branching” in the automation feature to solve this issue?

How would you envision that working?

I’m don’t know if the server, which would handle the addition through an automation, would ensure that no duplicates happen.

Top Labels in this Space