Preventing Multiple Users from Writing to the Same Row in AppSheet

I’m encountering an issue in AppSheet where multiple users unintentionally overwrite each other’s data because they are assigned the same row.

  • When a user opens the app, AppSheet loads the last used row from the cache, rather than fetching the latest data from Google Sheets.

  • If the user doesn’t immediately save their entry and another user opens the app, AppSheet assigns the same row to both users.

  • Since syncing happens after saving (not before), both users end up writing to the same row, leading to data loss.### Question:

    • Is there a way to force a sync before data entry to ensure that users always get the latest available row?
    • Or is there an alternative approach to prevent users from accidentally writing to the same row?

Unfortunately, there is no way to 100% avoid this issue due to the platform design.

AppSheet operates in a distributed fashion which allows it to support offline processing. This means EACH device gets its very own copy of the app and all allowed data. This also means that there is no way for a particular device to know about edits happening on any other device. All edits from all devices are submitted and the last one in wins.

There are a couple of simple ways to avoid this issue:

  1. Process change - adjust processes that use the app so that only a single user is ever editing a single row.

  2. Divide unrelated data into separate tables - often times a data table is built with too much unrelated information contained within it. If the data was placed into different tables then collisions can be avoided.

For instance, consider Order Placement and Shipping address. If these both are on the Order row and someone is editing order details at the same time another is updating the shipping address, they would collide and one would overwrite the other. Instead, Shipping Address is really a Customer attribute and they may have several addresses. So if Shipping Address was moved to an Addresses table, there no longer would be a collision. Order is updated on the order table and Address is updated in the Address table.

I hope this helps!

2 Likes

Hi @Watcharaporn ,

The answer by Gemini is unfortunately incorrect for the original question of this post thread. Any table’s row does need a unique key. However in AppSheet, just ensuring a unique key for each record will not guarantee the data will not be overwritten, if multiple users are simultaneously working on the same row(s).

@WillowMobileSys has nicely explained it with example and how you could avoid it.

If you perform rigorous testing with multiple users trying to update the same record, you should see the phenomenon of the data getting overwritten.

AppSheet’s own official help article explains it well. Please take a look at the below help article and the image of the relevant excerpt from that article.

So if I may add, I too have found using AI very useful. It does help or give good hints many times. However for critical questions as this, it needs to be carefully revalidated with other source of data such as previous questions, help articles etc.

1 Like

Just a placeholder post to provide background for my above post. In the above post, I replied to @Watcharaporn who had mentioned an AI assisted answer of creating unique key that will eliminate multiple users overwriting data issue.

I replied to @Watcharaporn with explanation in the above post and thereafter he/she deleted his/her post.