Lets say two users are at the same time making a change that decrements some count (maybe items in inventory). Each change would adjust that count to zero. Negative counts are not valid. If both users were making this change at the same time, as far as each device is concerned they are both making a valid change. The first user saves and the count goes to zero - all is ok. But the second user saves almost at the same time, the count in the data source goes negative and there is now a problem in the data.
This rare scenario doesnโt seem like it can be prevented up front when the app allows multiple users to change the same data. If there is, please let me know.
By the way, I do understand this is a common problem that has to be dealt with in any system where multiple users are changing the same data simultaneously.
So, I am wondering how some of you AppSheet developers might have or would react to this problem scenario so that it can be caught and corrected ASAP??
In your scenario it wonโt go to negative value because the start situation is the same for both users. When they are doing the update at the same time, they are both starting for example from value 2.
Ah, yes. I keep forgetting about that part (Iโll blame it this time on being away for weeks on vacation!)
But what would happen in this scenario:
Iโve got 3 users looking at an app, each displaying that weโve got 2 of something:
*User 1 orders 1 of the item
*User 2 orders 1 of the item
*User 3 orders both (seemingly available) items.
There needs to be something built into the system to flag user 3โs order and handle the fact that there is no available inventory.
Yes, great point! That is the main concern when the example app is an Order Placement app where available Inventory is critical (this is my actual use case). Obviously other app types might have other issues/concerns with similar data change scenarios and other apps may have no issue at all.
One option I can think of is running a Workflow as each record is entered or updated to validate values - in the Order placement app, validate available Inventory against open orders. An alert/message could go out to the user who entered/changed the offending record.
Another option, if time is not critical, is running a Report at the end of the day, notifying users of Inventory discrepancies.
Any other options?
Iโve come across this as well, and my solution was to implement a workflow that would flag orders that result because of this.
One workaround would be the sync checkโฆ if the last sync has happened more than few minutes ago, ask the user to sync before continue. Itโs not protecting 100%, but it can help a lot.
How can you force a sync checkโฆ Iโve been asking for that for months! Wellโฆ the ability to force a sync is what Iโve been looking for actually.
Linking to a particular app and force a sync:
CONCATENATE(โMyApp-123#at=โ, ENCODEURL(NOW())) will navigate to app โMyApp-123โ, force a sync, and display its default starting view.
Hmmโฆ have you ever tried implementing this as an action? So that you can โCall a sync?โ
I tested it, and it workedโฆ Not extensivelyโฆ
In my case I had to use an expression like this:
CONCATENATE("MyApp-123#view=My_View&row=",[Key],"&at=",NOW() + 1)
Only the + 1 forced the sync. That was a tip from @LeventK
What I have usedโฆ add a virtual column with app formula NOW() and use that DateTime value for verification when the app was synced.
Everyone, this is a great suggestion to help automatically minimize out of sync data. Iโll look into starting to use this function. Obviously, we would only want to use this virtual column sparingly - in forms/views where it is critical to have the most up to date data. Users will get frustrated having to wait on syncs all the time.
And as @Aleksi has pointed out, the โauto-syncโ function is not a 100% solution for the original posted problem and the issues that arise as discussed in the thread. So, I will likely implement a Workflow to check for issues and send an alert/email.
User | Count |
---|---|
36 | |
31 | |
28 | |
23 | |
18 |