web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power Apps – Concurren...
Power Apps
Suggested Answer

Power Apps – Concurrent edits overwrite data (SharePoint)

(0) ShareShare
ReportReport
Posted on by 2

Hi everyone,

I’m having an issue in a Power Apps app where multiple users edit and save the same SharePoint records at the same time. Data entered by one user sometimes gets overwritten and lost when another user saves.

I implemented this so far: I am comparing the currently opened record with the latest version from SharePoint before calling Patch()

  1. If identical → patch as usual
  2. If different → refresh the record and then patch

The problem is that refreshing the record removes all unsaved changes of the current user.

Therefore I thought of tracking the changes via OnChange variables and patch only modified fields, but this feels very complex (many fields, forms, attachments, people fields, etc.).

A locking mechanism is not desired by users.

Question:
Is there a recommended best-practice approach in Power Apps to handle concurrent edits and prevent overwriting other users’ changes when using SharePoint?

Thanks!

Categories:
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    You need to save the unsaved data and then put it back before patching so you are going to need a Table Variable. You would do something like
    If(
       ThisItem.Modified <> 
       Lookup(
          SPList, 
          ID = ThisItem.ID
       ).Modified,
       UpdateContext(
          {
             varSavedRecord:
             {
                Field1Name: Control1.Output,
                Field2Name: Control1.Output,
                . . . . . . . .
             }
          }
       ),
       Refresh(SPList);
       Notify(
          "Please save again as the record has been modified since you opened it",
          NotificationType.Information
       ),
       Patch(
          SPList,
          YourPatchHere
       );
       UpdateContext({varSavedRecord: Blank()})
    )
    Then the Default (or equivalent) of each control
    Coalesce(
       varSavedRecord.FieldName,
       ThisItem.FieldName
    )
    Also put at Screen OnVisible
    UpdateContext({varSavedRecord: Blank()})
    This way, you are temporarily storing the input and putting it back.
     
    You could also include a label under each field showing the current valueand make it Visible if it was different to the one in the Variable.
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for. Happy to assist further if not.
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn   
  • CU16011136-1 Profile Picture
    2 on at
     
    thank you so much for your answer. I thought about this solution but it seems quite complex for me. I have so much fields in the app, I would need to check every field if there were made changes. I tried it as I said with the OnChange property to save the changes in an variable to just patch then the fields that were changed after a refresh, but I got directly error with the field types etc. And thinking about to do this for 50 fields seems quite inconvenient.
     
    I thought about again to implement a locking mechanism (although the users are not happy about that), because I think this might be the best solution then in this case..
     
    Happy to hear about your thoughts!
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    A locking flag always has the issue of a user exiting the program and not removing the flag.
     
    You could set the Variable OnChange of each control, but this is probably just as much work as what I suggested first.
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard