Overlapping information

I have developed a scheduling application in which it is possible to choose the desired date and time, this data is already in a worksheet and the information will overlap the others. but I have a problem, when two people select the same time simultaneously, the information overlaps, is there a way to block the second modification, prevent the user?

0 3 591
3 REPLIES 3

I’m afraid that’s not possible because two users can fill the data at the same time. The last one always wins. Though you can add rule like when the user opens the form, you could check when the app was synced… if it’s more than few minutes ago, he/she would need to sync before filling that form. That won’t fix the duplicate probelm, but it can reduce it.

What rules could be used for this synchronization?

You’d have to record the time of the last sync, which is as simple as the expression, NOW(), in a virtual column. Virtual column app formulas are evaluated on each sync, so this expression would record the sync time each time a sync occurs. Then you an compare the current time against that stored sync time.

To record the sync time, you’ll need a row that will exist at the time of the sync and won’t change. A simple method is to create a table (e.g., SyncTable) with one normal column to contain a row key (e.g., id), and one virtual column to contain the sync time (e.g., syncwhen). Add a single row to the table and give the row an easy-to-use key value (e.g., 1). Then you can use LOOKUP() to get the sync time from there: LOOKUP(1, "SyncTable", "id", "syncwhen").

To discourage the user from adding a new row to the schedule table, you could add a column of type Show, with a category of type Text and a suitable warning message for Content, to your scheduling table. Use an expression for the column’s Show? property to compare the sync time and the current time and only display the column’s message if too much time (e.g., 5 minutes) has passed: ((NOW() - LOOKUP(1, "SyncTable", "id", "syncwhen")) > "000:05:00")

One way to prevent the user from adding a new row to the schedule table is to blank the new row’s key column value if the app needs to be synced; a row with a blank key column will be refused by AppSheet. This only works if the key column value is not user-provided. If the key column value is generated with an expression (e.g., UNIQUEID()), you can wrap that expression with an IF() that checks the sync time: IF(((NOW() - LOOKUP(1, "SyncTable", "id", "syncwhen")) > "000:05:00"), "", UNIQUEID()). The downside here is the error message the user sees won’t say anything about the sync time.

Another way to prevent the user from adding a row is to use the Valid if expression of an existing column to check the sync time. Then you’d also have to option of displaying a custom message to indicate what’s wrong.

Top Labels in this Space