Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Combobox in gallery loses its value after patch

(0) ShareShare
ReportReport
Posted on by 113

Hi,

 

I'm making a canvas app in which I have a gallery containing many fields to fill, each of them has a combobox linked to a dataverse table.

I need to store the new value in a collection which looks like this:

 

colVehiclesToAdd:
 vehicle1:
 field1 ("alimentation"):
 value
 field2:
 value
 vehicle2:
 field1:
 value
 ...

 


    ...

So I wrote this for the OnChange of my combobox:

 

Patch(
 colVehiclesToAdd;
 ThisItem;
 {
 alimentation: Self.Selected.Name
 }
);;

 

 
However, the selected value of my combobox randomly gets cleared after the Patch(). I guess it's because I use colVehiclesToAdd as the Items property of my gallery.

Any idea what I'm doing wrong?

Categories:
  • Verified answer
    BaptisteW Profile Picture
    113 on at
    Re: Combobox in gallery loses its value after patch

    Finally managed to fix this:

     

    First, I had to wrap my Field_Alimentations dataverse table in a collection so that the combobox stops resetting the selection. Then, it would create a duplicate record when patching my collection with the updated field. To fix that, I had to use the Update() method instead of a Patch(). Idk why, but it seems like Patch()'s behaviour is stupid with collections.

  • BaptisteW Profile Picture
    113 on at
    Re: Combobox in gallery loses its value after patch

    I tried to set the DefaultSelectedItems to First(Field_Alimentations) but it still doesn't work.
    (Field_Alimentations being a dataverse table containing only a "Name" column, acting as a list of possible values. They are correctly displayed in the combobox choices)

     

    Once I select a value, the attribute is correctly updated in my collection.

     

    The flex gallery looks like this:

    gallery.PNG

     

    My combobox's OnChange method:

    OnChange combobox.PNG

    My combobox properties:

    properties.PNG

    The updated collection:

    collection.PNG

    My dataverse table:

    db FieldAlim.PNG

     

    Edit :

    - My destination ("Parc") combobox isn't working, same problem BUT the patch doesn't update the collection at all when I set the DefaultISelectedtems property (it keeps the default value), which probably means that the current item in the gallery is reset

    - Seems like the value is kept if I choose the same value for the 2nd time

  • v-bofeng-msft Profile Picture
    on at
    Re: Combobox in gallery loses its value after patch

    Hi @BaptisteW ,

     

    Please set the combo box's DefaultSelectedItems property.

     

    If you don't know how to set it's DefaultSelectedItems property , please show me the combobox's items property.

     

    Best Regards,

    Bof

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard