cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dBrand
Helper III
Helper III

Update field in Gallery when button pushed

I have a collection in a Gallery. I have 3 buttons (1,2,3) that the user can push. When it is pushed, I want to update a different field (Item Qty) in the Gallery with a value (depending on which button they push). I also need it to prepopulate (the Item Qty field) with the saved value when first loading in the field, if it is already an existing record.

 

I am lost on how to do this. I can set the Text value to ThisItem.Qty, and it loads the value from the collection. But how do I then get the value to change when a user selects one of the buttons? I tried setting a variable, but that doesn't work, as it then updates all records in the collection/gallery.

 

I appreciate any help. Thanks!

8 REPLIES 8
WarrenBelz
Super User
Super User

Hi @dBrand ,

How are you deciding which record to update in the gallery - if it is the one currently selected, use the Variable you refer to, but have the Default of the control

If(
   YourVariableName>0 && ThisItem.IsSelected,
   YourVariableName,
   ThisItem.FieldName
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Thanks. Issue I then run into is when I click the Shift button on the second record (Check-in), it flips the first record (Cleaning) back to the default from the database. Would want it to stay at what I changed it to.

 

dBrand_0-1621979985415.png

 

Hi @dBrand ,

Yes, a gallery resets if something is run from inside it - you need to set another Variable on the OnSelect of the button

UpdateContext({varID:ThisItem.ID})

and then the Default of the field would be

If(
   YourVariableName>0 && ThisItem.ID = varID
   YourVariableName,
   ThisItem.FieldName
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

WarrenBelz
Super User
Super User

Hi @dBrand ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Sorry for the delay, My internet line was curt and is now back up. I tried this and see an issue I am running into. Since these records are being loaded into a Collection (then written back or created to the database when they click a save button at one time), any new records being added do not yet have a unique identifier (suck as ID or Key). Any way to still do this? Thanks. 

I used another field that would be unique, but still doesn't seem to work.

@dBrand ,

What exact code are you using (in Text please)

Thanks, I worked it another way for now, using a dropdown and flag. Seems to work.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,703)