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 / How do I use for all p...
Power Apps
Unanswered

How do I use for all patch to increment dataverse field by 1 in a dataverse table?

(0) ShareShare
ReportReport
Posted on by 77

Hi there, 

 

I am looking to have a button that, when clicked, increments the points column in a dataverse table by 1. The items come from a gallery labelled Gallery2_1. 

 

The formula must check against a unique column called Name and then update the points column in that record. 

 

Here is what I have tried, but it is not working. 

```

ForAll(
Gallery2_1.AllItems,
Patch(
Students,
LookUp(
Students,
Name = ThisItem.Name
),
{
Housepoints: ThisItem.Housepoints + 1
}
)
)

```

Categories:
I have the same question (0)
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @lmcc 

     

    I just did some rewriting but still similar idea to what you did:

    With({
    	_items: Gallery2_1.AllItems
     },
    	ForAll(_items As X,
    		Patch(Students,LookUp(Students,Name = X.Name),
    			{
    				Housepoints: X.Housepoints + 1
    			}
    		)
    	)
    )

     

  • lmcc Profile Picture
    77 on at

    @cha_cha That is incredible. Please could you explain this code to me? 

     

    Just wow!

     

  • cha_cha Profile Picture
    4,932 Moderator on at

    Did it work?

     

    I use the With function cause I like it when the code is tidy. It allows me to store the data on a temporary variable. This means the variable/property _items can only be within that With Function. 

     

    Also, the correct format to call records within a loop (ForLoop) is ThisRecord, not ThisItem. But I don't like ThisRecord cause it's long that is why I use X as a replacement for it. And I just did the same Patch as you did using X.

     

    Lastly, I'm unsure if the code works fine with just the code below. ForAll/Patch doesn't work together if you are patching looping and patching the same data source.  This is why I use With. Technically, Gallery2_1.AllItems and Students are different data sources, so the code without the With function could work. It was just a habit of mine.

    ForAll(Gallery2_1.AllItems As X,
    		Patch(Students,LookUp(Students,Name = X.Name),
    			{
    				Housepoints: X.Housepoints + 1
    			}
    		)
    	)

     

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard