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 / Combobox in gallery lo...
Power Apps
Answered

Combobox in gallery loses its value after patch

(0) ShareShare
ReportReport
Posted on by 124

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:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    on at

    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

  • BaptisteW Profile Picture
    124 on at

    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

  • Verified answer
    BaptisteW Profile Picture
    124 on at

    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.

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard