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 / Retain the selected va...
Power Apps
Unanswered

Retain the selected value of an option set dropdown in a gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hey Everyone,

I have a dropdown inside a gallery whose values are derived from an option set field of an entity. When I make a selection and save the data using a collect statement, I am able to see the selected values in the CDS(the entity where I stored the saved data). However, the dropdown for all entries resets itself to a certain value on the screen(not the specified default value). I am looking for a way to display the selected value in the dropdown and potentially extract those values from the CDS.

I tried:
1. Setting 'Reset' property to false
2. UpdateContext({ResetVar: false}) on 'Save' and added 'ResetVar' to 'Reset' property
3. Tried to set default property to Parent.Default(error)
4. Tried to set default property to Dropdown2.SelectedText/Dropdown2.Selected.Value(cannot do this action for a record so tried converting to a text which also did not work

 

I would appreciate it if someone can help me with this!

Categories:
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous 

    Could you tell me :

    What is your code for saving data?

    Where is this code?

    What is the dropdown controls default property?

    I think the key point is the dropdown controls default property.

    I made a similar test but did not encounter the problem you mentioned.

    Here is my solution:

    my data source: EntityAS

    Field name

    Field type

    myoption

    Option Set

    1\Add a gallery(Gallery5)

     Items: 

     

    EntityAS

     

    2\add a dropdown control(Dropdown3) into Gallery5.

    Items:

     

    Choices(myoption)

     

    OnChange:

     

    Patch(EntityAS,Gallery5.Selected,{myoption:Dropdown3.Selected.Value})

     

    Default:

     

    ThisItem.myoption

     

     

    Best Regards,

    Bof

    1.jpg
    2.jpg
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-bofeng-msft

     

    Hey,

     

    I managed to get the issue sorted out. I had a small issue in the data source and the default property was showing me the correct options once I fixed that problem. Although, all those changes have created a problem in save as my collection errors out for a weird reason. I am trying to collect the data and write it onto a CDS and it says I do not have that collection. I am not sure whether those problems are related. I have attached the screenshots. It was working fine earlier and I was able to write data to CDS

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

    Hi @Anonymous :

    From the attachment you added, the problem seems to be in the collection.

    How was this collection created? Have you defined it elsewhere?

    Are you willing to try to create a new collection and try again?

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey @v-bofeng-msft 

     

    I tried to resolve it using a different method and I fell short at the 'save' step. I have explained the steps clearly in the attachment. I would really appreciate if you take a look at it!

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

    Hi @Anonymous :

    If you want to automatically pre-perform certain actions when you open the app, I suggest you consider OnStart property.

    PowerApps OnStart and OnVisible Development Tricks

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey @v-bofeng-msft

     

    I have attached the responses to all the questions you have asked.

     

    I added the patch command to the Onchange property and it said I have invalid arguments. I need the data to be displayed when I close and re-launch the app. My assumption was it will not work with a collection.

     

    I cannot patch it to the CDS as I am collecting all the skills and expertise levels which will be stored on clicking Save.

     

    Please refer to the screenshots which have detailed information. I would really appreciate your help with this!

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

    Hi @Anonymous :

    Many reasons:

    Firstly,the gallery's data source is not your entity it's the return value of a combo box control.

    Secondly,You first delete the record you want to update, which will inevitably lead to errors in other controls that depend on this record.

    I suggest you use Patch to update records instead of deleting a record then adding a record.

     

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Duly noted. I will try to implement a logic that does not follow these steps. However, both of them work fine now and I am able to save the necessary information in the CDS(as indicated in the screenshots). My only issue is with retaining the selected value of the gallery dropdown. I will try to find something to fix that issue. I really appreciate your help with this. Thank you so much

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

    Hi @Anonymous 

    The most convenient method is to use the standard field "Modified On" of the entity. 

    You can get the record you recently updated by this code:

     

    First (Sort (your entity, 'Modified On', Descending))

     

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey @v-bofeng-msft ,

     

    I tried to include the piece of code you sent on the Default property of dropdown, the deafultselecteditems on gallery and the onVisible property of screen. None of them worked.

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
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard