Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Reset ListBox on form

(0) ShareShare
ReportReport
Posted on by 15

Hello,

 

I am still a novice on PowerApps and I am stuck on a dropdown list that does not reset when I want to switch the form to add mode...

 

I have a button that allows me to switch to another screen in add mode with the following formula:

Set(varEditMode;"AddNew");; Navigate(Client_Details;ScreenTransition.Cover;{})

 

When I want to view the data, I have the following formula on the OnSelect of my Gallery:

Set(varEditMode; "ReadOnly");; Navigate(Client_Details;ScreenTransition.Cover)

 

My form's data source is: 

LookUp(tabClients;cl_ID=Clients_Gallery.Selected.cl_ID)

 

My dropdown list has the source: tabEntites

The displayed value: en_Libelle

The Default property is set to:

LookUp(tabEntites;en_ID=ThisItem.cl_ID_Entite;en_Libelle)

 

When I switch to add mode, ThisItem.cl_ID_Entite is indeed empty, but the text displayed in my dropdown list remains stuck on the last displayed value.

 

Do you have any ideas to solve my issue, please?

 

Thank you in advance.

Categories:
  • SpongYe Profile Picture
    SpongYe 5,378 on at
    Re: Reset ListBox on form

    @Gado 

     

    Yeah you have to do it another way in Powerapps. Good luck further. 

    It would be also good to others to see that your problem got solved by accepting a answer for this topic. 

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • Gado Profile Picture
    Gado 15 on at
    Re: Reset ListBox on form

    Hello,

     

    Okay!

    So, in PowerApps, we can't do something like in VBA where we say ListIndex = -1?

     

    By adding an empty row in my tabEntites, it actually solves the issue for me. The database is on Excel.

     

    It's a bit special:)

     

    Thank you for your help once again.

  • Verified answer
    SpongYe Profile Picture
    SpongYe 5,378 on at
    Re: Reset ListBox on form

    Hi @Gado,

     

    You want a blank value as the defualt value also after resetting.

    You need to have the blank value in you datasource or collection:

     

    ClearCollect(
     colDropDownSample, 
     {Value:""}, 
     DropDownSample
    );

     

    Than the Dropdown Default propety need to be:

     

    ""

     

    SpongYe_0-1701434923443.png

     

    And then after every reset you will get no pre-selection in the dropdown list.

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

     

  • Gado Profile Picture
    Gado 15 on at
    Re: Reset ListBox on form

    Hello,

    In your demonstration, the values in the lists default to 1.

    What I'm trying to achieve is to have no pre-selection in the dropdown list.

    Is that possible?

  • SpongYe Profile Picture
    SpongYe 5,378 on at
    Re: Reset ListBox on form

    Hi @Gado 

     

    I tried is also with a dropdown and a listbox:

    SpongYe_0-1701432200559.gif

    Both working. 

     

    Can you elaborate more on where you reset the code?

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

  • Gado Profile Picture
    Gado 15 on at
    Re: Reset ListBox on form

    Hello SponYe,

     

    Thank you for your help, but it hasn't changed anything.

    I still have a display issue.

     

    Furthermore, if I create a new record without changing the value of the dropdown list, it retains the displayed value as data.

  • SpongYe Profile Picture
    SpongYe 5,378 on at
    Re: Reset ListBox on form

    Hi @Gado 

     

    You do this by setting the Reset property of any control to a context variable, say ResetVar.

     

    Then you put this code into whatever event you want to trigger the reset (e.g. a button OnSelect or a OnVisible or OnHidden etc.)

     

     

    UpdateContext({ResetVar: true}); UpdateContext({ResetVar: false})

     

     

    Then all of the controls with ResetVar as Reset property will be simultanaously reset to the Default value.

    SpongYe_1-1701429375441.png

    SpongYe_2-1701429382809.png

     

     

     

     

     

    If you have any questions or feedback, please let me know. Have a great day! 😊

    -----------------------
    PowerYsa Power Platform Enthusiast [LinkedIn] | [Youtube]

    I love to share my knowledge and learn from others. If you find my posts helpful, please give them a thumbs up 👍 or mark them as a solution ✔️. You can also check out my [@PowerYSA] for some cool solutions and insights. Feel free to connect with me on any of the platforms above. Cheers! 🍻

     

     

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard