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 Apps
Answered

ETAG Mismatch

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am currently trying to update a record with the following code:

 

 

Refresh(Ressources);;
If(
 ThisItem.Active = 1;
 Patch(
 Ressources;
 ThisItem;
 {Active: 0}
 );;
 UpdateContext({varIsActivated: false});
 Patch(
 Ressources;
 ThisItem;
 {Active: 1}
 );;
 UpdateContext({varIsActivated: true})
)

 

 

Somehow I run into the ETAG Error Message. I already viewed other posts about this problem. I am using this code on the OnSelect property of an icon. 

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Remove the Refresh from your formula and consider the following change:

    Patch(Ressources;
     {ID: ThisItem.ID;
     Active: Abs(ThisItem.Active-1)
     }
    );;
    UpdateContext({varIsActivated: Abs(ThisItem.Active-1)=1})
    

     

    Refreshing your datasource is going to refresh all the records and your current Item will not be in sync any longer.

     

    Do you have a particular need to refresh??

     

    I hope this is helpful for you. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I am building a desk reservation app and I want the admin to be able to enable and disable individual tables. At first we had several lists and in each list the different tables. Now we have one list for all resources. With the old code everything worked fine. 

     

    Old Code:

    If(ThisItem.Active = 1;
     Patch(
     Switch(
     ddChooseDeskList.Selected.Value;
     "Rodund IT"; DesksIT;
     "Rodund Personal"; DesksPersonal;
     "Rodund Telekom"; DesksTelekom
     );
     ThisItem;
     {Active:0}
     );
     Patch(
     Switch(
     ddChooseDeskList.Selected.Value;
     "Rodund IT"; DesksIT;
     "Rodund Personal"; DesksPersonal;
     "Rodund Telekom"; DesksTelekom
     );
     ThisItem;
     {Active:1}
     )
    )

     

    New Code that doesn't work:

    If(
     ThisItem.Active = 1;
     Patch(
     Ressources;
     {
     ID: ThisItem.ID;
     Active: 0
     }
     );
     Patch(
     Ressources;
     {
     ID: ThisItem.ID;
     Active: 1
     }
     )
    )
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Yes, you can first cut some of the duplication with changing that formula to:

    Patch(
     Ressources;
     {
     ID: ThisItem.ID;
     Active: Abs(ThisItem.Active - 1)
     }
    );

     

    Now, with that formula, the only reason you would get an ETAG mismatch is if the record of the datasource is somehow being modified by another user.  Is that perhaps what is going on?  Or, are you getting the ETAG mismatch on every occurrence of the formula evaluation?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I got rid of the ETAG mismatch but now when I click on it, it will only change on the SharePoint List but in the app it doesn't change. When I click it again nothing is happening.

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    So what is the Items property of your Gallery?  Is it direct to your datasource?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    No it's not. I am getting a collection of the tables from another screen in my app

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    No it's not. I am getting a collection of the tables from another screen in my app.

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    There's the issue!  Collections are snapshots of data.  They do not update.  You have to update them.

    I would suggest working directly with the datasource rather than a collection, unless there is some need to have an in-memory database for adding/removing and editing records, which is what a collection gives you.

     

    Beyond that, you will either need to update your datasource AND your collection at the same time, or Revert the record (i.e. refresh the record) in your collection, or re-collect your entire collection again.

    Those are in order from least impact on performance to the most.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard