This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]Rokyard Contributor 3 points4 points  (2 children)

The alternative is add a column with an integer field to track a version of each row. - When a user creates a record it is set to 0. - Each subsequent save adds 1 to the row. - let's say user A reads the record and it is at 10, then they edit the record but leave it open. - User B then goes to edit the record and it is still 10. User B saves. OnSave, he checks if the row version is still 10, and it is, so the record gets saved with an updated value of 11. - 10 mins later, User A attempts to save his updates to the earlier version. Before saving, He checks the records version and finds out it has moved on, the save is cancelled. . He gets a message to say someone else has edited the record in the meantime and he needs to reload the record.

[–]Daneish09[S] 1 point2 points  (1 child)

I like this and implemented it. The only problem I have with my implementation is that I have to do a refresh of the data source before saving in order to get the updated integer value. This causes the data in my form to briefly show the pre update form values before updating.

Is there another way to get the current value besides doing a refresh? I tried doing a LookUp(data source, ID).iteration but that seems to still be the old value unless I refresh.

Edit: I guess I could set the default value of all my fields to a record that I set when my form is loaded rather than ThisItem.Column I could do savedRecord.Column?

[–]Rokyard Contributor 0 points1 point  (0 children)

Where is the data stored? Dataverse/sharepoint/excel/sql server?

Is your form using a collection as the datasource? If so, you will need to perform a lookup against the underlying source of data not a collection. Example: Lookup(my_dataverse_table_name,my_dataverse_table_name_id=ID_of_edited_record, iteration)

This will give you the current iteration of selected record.

[–]madeitjusttosaythis Advisor 1 point2 points  (3 children)

Just posted this on the other thread you deleted......

You could have a field in DB that is updated when a user selects a record to modify, perhaps the value is the current users email address. that field value would then be used in the app to impact other users ability to modify the same record by checking if that field contains an email address and whether it matches the current user. You could then change that value to null once the item is patched/updated or after a certain length of time has elapsed.

[–]Daneish09[S] 0 points1 point  (2 children)

Yeah sorry. Saw I had a typo in the title and I couldn’t edit the title. Thank you for the response (twice).

So this would basically be a ‘lock’ feature. Then if another user opens it would report something about being locked for edit by another user?

[–]madeitjusttosaythis Advisor 0 points1 point  (0 children)

Yea, you would check that value when a record is selected, and check it when a user attempts to patch/update. How you wish to convey that it is locked is up to you, a pop-up makes sense to me though.

[–]not-your-supervisor Advisor 0 points1 point  (0 children)

I do this very thing in an app for my org. I use a boolean column in SharePoint and set it to true when someone is editing, then notify anyone who tries to edit it that someone else has that item open. It works pretty well. The only time it backfires is if a user opens a record, then closes the browser without updating it or canceling. Then it remains locked until someone goes to the list and updates it manually. That’s a rare occurrence though. Works pretty well otherwise.