cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jharville
Helper V
Helper V

When a button is clicked, increment Number column's item in SharePoint list by +1

Hello all,

 

I have an app where there is a main landing screen:

 

jharville_0-1649434536668.png

 

 

When the 'Service Gateway' button is clicked on the bottom, I want it to increment the 'Number of Clicks' column (type: Number) by +1.

 

 

jharville_1-1649434606582.png

 

How would I go about doing this? I've tried other forum posts that reference 'ThisItem' but that isn't coming up as a usable variable for me. 

 

Ex: someone said to use something similarly formatted to this: 

Patch(Ideas, ThisItem, {Votes:ThisItem.Votes+1})

 

 

Thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@jharville 

ThisItem would be in context of a control that has an Items property.  Your buttons appear to be free-standing and not part of a gallery.  And, based on your datasource picture, there would be no need anyway.

It looks like you have a single record, single column list for this.

So, your formula would be:

With(First('ServiceGateway Button Tracker'),
    Patch('ServiceGateway Button Tracker', {ID: ID, 'Number of Clicks': 'Number of Clicks' + 1})
)

 

Keep in mind though that due to how PowerApps gets its data, the number of clicks in the app may not reflect the current value in the list and results may not be what you expect.

You could perform a Refresh prior to the above formula, but that may have negative impacts on your app performance.  If not a problem, then utilize that.

If it is an issue, you can utilize a PowerAutomate flow instead to perform this outside of the app.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@jharville 

ThisItem would be in context of a control that has an Items property.  Your buttons appear to be free-standing and not part of a gallery.  And, based on your datasource picture, there would be no need anyway.

It looks like you have a single record, single column list for this.

So, your formula would be:

With(First('ServiceGateway Button Tracker'),
    Patch('ServiceGateway Button Tracker', {ID: ID, 'Number of Clicks': 'Number of Clicks' + 1})
)

 

Keep in mind though that due to how PowerApps gets its data, the number of clicks in the app may not reflect the current value in the list and results may not be what you expect.

You could perform a Refresh prior to the above formula, but that may have negative impacts on your app performance.  If not a problem, then utilize that.

If it is an issue, you can utilize a PowerAutomate flow instead to perform this outside of the app.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

The code worked perfectly, thank you! I do have a quick question, what did you mean by "the number of clicks in the app may not reflect the current value in the list and results may not be what you expect" ?

 

The goal of ours is to track the total amount of clicks (conducted by everyone in our organization that has access to the app) in the SharePoint list. I did a few tests myself and it seems functional.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,119)