I fixed the problem via coding. I dont see any automatic solution to record locking.
Case closed.
I have an application that allows end users to click in a table row to select it and assign or unassign themselves to two text fields. Everything works perfectly. However, If two people do this function at the same time, one overrides the other’s changes. Here’s the processing…
The table looks something like this:
User 1 User 2 Date Start End
Joe Blow mm/dd/yyyyy hh:mm hh:mm…
mm/dd/yyyyy hh:mm hh:mm…,
…
[ Save ]
A user clicks on a row, say row 1 above to assign himself to the cell in the first row. The code inserts the current user’s name in the User 1 column in row 1 and then writes the row back to the collection using this code:
let rowData = {
_id: row_id,
title: rowtitle,
user1: rowuser1,
user2: rowuser2,
…
};
$w(“#table1”).updateRow(workrow, rowData);
wixData.save(“Schedule”, rowData) // update the row in the underlying collection
.then((results) => {
let item = results; //see item below
$w(“#text30”).text = message + “on " + rowdate
}) // Error
.catch((err) => {
let errorMsg = err;
$w(”#text30").text = ("update error: " + errorMsg)
console.log("save filed: " + errorMsg)
});
If a user selects a row, Presses “Save” his name replaces User 1. If at the same time, another user is looking at that same row and sees it is , after selecting it, his name overwrites the other user’s name when he presses save.
Question: Should Wix use the record’s underling update time to sense that user 1 changed the row before user 2 tries to change the same row, knowing that the update has been changed prior to user 2 pressing “Save”, thus raising an error condition indicating that “another user has changed this same record” or something like that.
Or do you have to code your own record locking strategy? Please advise. Obviously, having to code a concurrent update strategy to manage changes to the underlying database adds orders of complexity to the coding. It would seem that the updateRow action should manage the timestamps and trigger an error if the row’s timestamps changes between updates. Thanks.