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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch to SharePoint li...
Power Apps
Unanswered

Patch to SharePoint list only works once

(0) ShareShare
ReportReport
Posted on by 254

My app contains a gallery, each item in the gallery has a view button, in the OnSelect property of the button I am using this function: Patch(Datasource, ThisItem, (ViewCount: ThisItem.'View Count' + 1});

 

If I run the app and press the button, the View Count column for the current item in PowerApps is incremented by 1 which is correct, however, this only works the first time I press the button, if I press it multiple times afterwards nothing happens in my SharePoint list.  I just want to increment the view count by 1 each time the button is pressed but this doesn't seem to be working after the first press, what am I doing wrong?  TIA.

 

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    Try:

    Patch(Datasource, ThisItem, {'View Count': ThisItem.'View Count' + 1})

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

     

  • Manc_Gurl Profile Picture
    254 on at

    There was a type in my original post I noticed, it should have read: 

    Patch('Data Source', ThisItem, {'View Count': ThisItem.'View Count' +1})

    I tried amending as per your instruction but I get the same results, works on the first press then nothing happens if I press the button again.  I'm using a collection as the datasource on my gallery, the patch is going to my SharePoint list, the same list that is used to create the collection for my gallery.  I can't understand why it increments the view count once but not again unless I restart the app.

  • Verified answer
    eka24 Profile Picture
    20,923 on at

    The formula is ok. Thisitem refers to that particular item being clicked. So if the item is 3 clicking will make it 4. The issue is the Gallery is not refreshing to capture the new figure that's 4+1 to 5.

     

    Since you are using a collection, you will have to refresh the collection. Is It on OnVisible of the screen, then after Patching, to to other screen for it to refresh.

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Manc_Gurl Profile Picture
    254 on at

    The Gallery does update, I am already refreshing it, the issue is the that the SharePoint list only gets updated once, on the first click of the button, any clicks thereafter do not update the SP list unless I close and restart the app.  This is why I'm scratching my head, I don't understand why it only adds +1 once 🙂

  • eka24 Profile Picture
    20,923 on at

    Once when you restart it work then it definitely go to do with refreshing or caching

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Manc_Gurl Profile Picture
    254 on at

    I think I might have to start over with the button, it's giving me all sorts of crazy errors now even after deleting the function and typing a new one in.  Something is not right.  My gallery was refreshing and now it's not.  🤔

  • eka24 Profile Picture
    20,923 on at

    That is fine

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • Manc_Gurl Profile Picture
    254 on at

    OK it works now, I think your solution was correct, it was a refreshing/caching issue in the gallery so I will mark your answer as the solution 🙂

     

    I eventually got it to work using this function in my button which sits inside my gallery items.

     

    Patch('MyDatasource',ThisItem, {'View Count': ThisItem.'View Count' + 1}); Refresh('MyDatasource'); ClearCollect(MyCollectionName, 'MyDatasource')

    The gallery is refreshing immediately after the button click and if I click the button again my SP list is updated again.  Thank you for your help. Much appreciated.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard