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 / Changing value in gall...
Power Apps
Unanswered

Changing value in gallery onchange event

(0) ShareShare
ReportReport
Posted on by 2

Hi

I have an image field in a gallery that I want to toggle between a "question-mark", "Approved" or "Unapproved" image when the user clicks on the image. When the user clicks the image the field ThisItem.Approved (which is a column in the database) should toggle between Blank(), 1 and 0 but for some reason I cant get this to work. I followed this https://powerusers.microsoft.com/t5/Building-Power-Apps/Within-a-Gallery-Set-the-value-of-a-Textbox-Checkbox-quot/m-p/283593#M82156 thread but my desired functionality is just a bit different and it just doesnt work for me.

I have an image set up with three different images. I can toggle between them if I put the following in the OnChange for the image (so I know toggling the image works):

UpdateContext( {cvApproved:cvApproved+1} );

and in the Image property:

If( cvApproved = 1, MyApproved , If( cvApproved = 2, MyNotApproved, MyQuestionMark ))

but obviously this isnt a working solution (it doesnt toggle around and also all of the rows toggle together).

If I change the Image property to:

If( ThisItem.Approved = 1, MyApproved , If( ThisItem.Approved = 2, MyNotApproved, MyQuestionMark ))

and the OnSelect code to:

If( ThisItem.Approved = 0, ThisItem.Approved = 1, If( ThisItem.Approved = 1, ThisItem.Approved = Blank(), ThisItem.Approved = 0 ))

it doesnt work.

How can I make this work???

Thanx!

Categories:
  • leyburn19 Profile Picture
    2,157 on at

    You need to  update the datasource for this to work.  Add something like this to the onslect:

     

    If(ThisItem.cvApproved =1,Patch(Source,First(Filter(Source,ID=ThisItem.ID)),{Approved:2}),If(ThisItem.cvApproved =2,Patch(Source,First(Filter(Source,ID=ThisItem.ID)),{Approved:1}))

     

    That should update the record in the table, thereby changing teh status for the image and your image formula should work

     

     

  • hebj Profile Picture
    2 on at

    Thanks for your reply but that wont work with the rest of my business logic im afraid. Im not saving the changes until the user clicks a Save button. I just need to store the current Approve/Not approved state on each row until the user hits save or cancel.

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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard