cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MattyJ_09
Level: Powered On

Lock item when someone is editing

I'm trying to figure out a way to stop two people from being on the same Edit Form at the same time.  So I have a gallery and when you click on the arrow it takes you to another screen where you can edit information about that specific item.  The issue is we can have multiple people in the app at the same time but we don't want two people to be doing the same request at the same time.  I would like for the app to disable the submit button and have a label show up that says "This item is locked by <user email>.".  

1 ACCEPTED SOLUTION

Accepted Solutions
cwebb365
Level 10

Re: Lock item when someone is editing

If the built in error checking isn’t enough. You can always have the app add a lockedby value in a column you add to a database somewhere. This will require an online connection and a database call however.

Then when you form loads you check for a value in that column if it doesn’t exist then you lock it with the current user and patch that change to the dB. If there is a lock you display error with the locked by column value to the user and disable the button.

Now you also need to build in some kind of release for locks as well in case someone doesn’t save a value or quits the app or it crashes. So similar to how SharePoint does it runs an unlock process every five or ten minutes looking for locked records and remove the locks.

Or you could also give the user the ability to remove a lock if it’s locked but that could cause issues. Or maybe only give them the option when a record has been locked for more than 10 minutes.

That said you would need to also have a lockedon column with how long the column has been locked for so you can do the 10 minute user option or 10 minute auto clean out. But maybe records could be open longer then 10 minutes you would need to adjust.


Anyway just a couple ideas of how you could quickly handle or add some lock logic into your app.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Lock item when someone is editing

Hi @MattyJ_09,

 

The apps made in PowerApps are multiuser. They each are their own instances so it does not matter how many users use it at the same time. If multiple users edit the same record at the same time, only single one user could edit the record, the other users would face conflict error within their app.

 

More details about the errors type within the app when submitting the form, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-errors#description

 

Regards,

Mona

 

Currently, you could re-edit the same record only when the other user saved his/her modification into the SP list.

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
cwebb365
Level 10

Re: Lock item when someone is editing

If the built in error checking isn’t enough. You can always have the app add a lockedby value in a column you add to a database somewhere. This will require an online connection and a database call however.

Then when you form loads you check for a value in that column if it doesn’t exist then you lock it with the current user and patch that change to the dB. If there is a lock you display error with the locked by column value to the user and disable the button.

Now you also need to build in some kind of release for locks as well in case someone doesn’t save a value or quits the app or it crashes. So similar to how SharePoint does it runs an unlock process every five or ten minutes looking for locked records and remove the locks.

Or you could also give the user the ability to remove a lock if it’s locked but that could cause issues. Or maybe only give them the option when a record has been locked for more than 10 minutes.

That said you would need to also have a lockedon column with how long the column has been locked for so you can do the 10 minute user option or 10 minute auto clean out. But maybe records could be open longer then 10 minutes you would need to adjust.


Anyway just a couple ideas of how you could quickly handle or add some lock logic into your app.

View solution in original post

MattyJ_09
Level: Powered On

Re: Lock item when someone is editing

I was able to get something very similar to this worked out.  When they press the button to go into the edit form screen I have a patch happen that sends the logged in users email address to the database.  Then once they are on the screen I have the submit button disappear and an unlock button appear based on the value in the database.  I did bring in a gallery (that filters only the data that was clicked into) and a timer that refreshes the gallery every ten seconds.  So if someone goes into the app and unlocks the edit form for the particular entry then the other persons page shows the lock button.  I'm sure I may have been able to find a better solution but for what we need it for it will work. 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 172 members 5,206 guests
Recent signins:
Please welcome our newest community members: