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 / Setting items in a gal...
Power Apps
Unanswered

Setting items in a gallery for icon or buton click

(0) ShareShare
ReportReport
Posted on by 260

I have a gallery whose items have a quantity field from a SP list.  I want users to be able to select the value in that field as a default or else enter a new quantity.  I added another field, "QTYNEW" in the list as well.

 

On the gallery, I display QUANTITY but have a text input whose default is QTYNEW.  As it should the text input is blank.  I also added a button in the gallery (so it appears on each line) that I want make the text input field set to from the QUANTITY field when the button is selected.  I tried thsese for ONSELECT:

 

gallery.selected.textinput = text(gallery.selected.quantity)

 

gallery.selected.textinput=text(thisitem.quantity)

 

I also added a label and tried those expressions to set its text.  When I click the button, nothing seems to happen.

 

However, if I change the ONSELECT to SET(varname, text(thisitem.quantity)  and add a label with varname as its text value, it works.

 

The problem with that is that i need the text input field for each row in the gallery to be distinct, so I cannot use one variable.  What happens on any row is separate and distinct from the others.

 

Would using an array solve this problem?  Meaning that for each row, an item in the array would get the desired value.  But then i have another problem:  ROWS DO NOT HAVE TO BE PROCESSED IN ORDER, OR PROCESSED AT ALL!

 

Greatly appreciate any suggestions.

 

Oh, one more issue: when a row's value for this is set, I want to fill the row with a different color that persists. 

Categories:
I have the same question (0)
  • v-albai-msft Profile Picture
    Microsoft Employee on at

    Hi @lmheimendinger ,

    Do you want to populate the Textinput for selected item when its button be clicked? And leave other items (not selected) blank? Like below?

    v-albai-msft_0-1618219449142.png

    If yes, as you mentioned, variable will make all rows have a same value (I also tried some other methods, but cannot achieve this requirement) .

    So I would suggest you try Patch function. By default, "QTYNEW" in the list is blank(without any value). When button clicked, the selected item’s QTYNEW will be update. Formula like below:

    v-albai-msft_1-1618219449146.png

     

    v-albai-msft_2-1618219449149.png

     

    Besides, if you don’t want to update your SP list, you can create a collection based on this list using “Clearcollect(test1,listname)”, then use this collection in your gallery and also update this collection each time.

     

    For your second question, you can set TemplateFill property of Gallery based on ThisItem.QTYNEW. Formula like this:

    If(!IsBlank(ThisItem.QTYNEW),Red,White)

    v-albai-msft_3-1618219449152.png

    Best regards,

    Allen

  • lmheimendinger Profile Picture
    260 on at

    Thanks for the suggestions.  PATCH may be easier, and I do want an "undo" button for each item, so that would just require a reversal PATCH, too.   I still find it a shortcoming that you cannot set an individual item in a single line of another item in a gallery.  I am not understanding why technically this isn't a thing....

     

    On the row color, I use TempplateFill to indicate the selected row:  If(ThisItem.IsSelected,LightYellow,White) so I don't want to lose that capability.  Would it work to use nested IFs so to look at whether QTYNEW !ISBLANK first and set the color to say red but follow with second IF as above ?  Play time I guess.

     

    Thanks.

  • lmheimendinger Profile Picture
    260 on at

    Well thought I had this but it didn't work.  

     

    Onselect for button :  

    Patch('Sales Orders Line Items',ThisItem, {'QTY Picked':ThisItem.Quantity} ); Refresh('Sales Orders Line Items')

     

    Got no errors, but the list 'Sales Orders Line Items' column Qty Picked did NOT update, and of course the text input field where that is the default value did not change either.  I can see SOMETHING is happening as the ant dots momentarily appear across the screen.  I also refreshed list view but Qty Picked still didn't show as updated.   Here is a work in progress look at the gallery.....  When I click on button, the text input field (tan) should have the same value as the Quantity field above it.

     

    picked_detail.jpg

  • lmheimendinger Profile Picture
    260 on at

    Well I must be mistaken.  The PATCH worked and the Qty Picked was updated but it does not appear in the text input field until I exit that screen and re-enter the screen again.

     

    I also did a RESET on the text input field instead of a REFRESH on the data source.  Didn't work.

  • v-albai-msft Profile Picture
    Microsoft Employee on at

    Hi @lmheimendinger ,

    1. Does your gallery directly use the SP list as data source? Or a collection?  

    If it directly uses your SP list and your SP list update successfully, Refresh('Sales Orders Line Items') should work. This did work on my side.

    2. You can try below formula to set the color. This time, no matter other conditions,  just IsSelected, the color will be LightYellow. 

    If(IsBlank(ThisItem.mode)&&ThisItem.IsSelected=false,White,ThisItem.IsSelected=true,LightYellow,!IsBlank(ThisItem.mode),Red)

    Best regards,

    Allen

  • v-albai-msft Profile Picture
    Microsoft Employee on at

    Hi @lmheimendinger ,

    How are things going? Is my reply helpful to your issue?

    I am willing to hear from you.

    Best regards,

    Allen

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 429 Most Valuable Professional

#2
11manish Profile Picture

11manish 191 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 122 Super User 2026 Season 2

Last 30 days Overall leaderboard