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 / How do I get an edit f...
Power Apps
Suggested Answer

How do I get an edit form combo boxes to behave the way I want them too?

(1) ShareShare
ReportReport
Posted on by 831 Moderator
I originally asked this question back in July but had to put the project aside. That and there were no good solutions at the time. You can read my post here. https://community.powerplatform.com/forums/thread/details/?threadid=bb02a0b8-bc4e-ef11-a317-6045bdd88b0e
 
I am revisiting this and figured I'd try and lay out the situation again and see if we can come up with a good strategy, 
 
Here is my situation
  1.  I have a gallery that returns records from Dataverse table
  2. When you select a gallery item the record is written to a global variable (I used a global variable because there is also a copy record function on the page that navigates the users back to the original form and populates it with the copied record for editing)
  3. I have a form on the page that uses the global variable data as the Items property
  4. In the form I have some dependent combo boxes. These function as expected. When and item from the parent is selected the values available in the child combo box are changed.
This all works fine. But I am having issues with the behavior I want the child combo boxes to have. Here is what I want to happen.
  1. When a parent combo box is changed I want the child combo box(es) to appear blank.
  2. If the child combo box is required I want that to be respected by the form
My issue has been how to get this to work. Here is what I have tried. 
  1. For the parent combo box I am setting the OnSelect property to a context variable 
    UpdateContext({varResetSubLedgerReview: true});
  2.  I set the Reset property of the child to this value 
    varResetSubLedgerReview
  3. The DefaultSelectedItems for the child combo box is
    {Value:If(varResetSubLedgerReview,Blank(), Parent.Default)}
This works the first time around but fails if I were to change the parent combo box again since the variable is still set to true.
I've tried setting the variable back to false using the OnSelect of the child combo box. That does work to reset the variable, but the side effect is that the logic in the DefaultSelectedItems, for the child, fails. Instead of the blank remaining it is replaced with the Parent.Default. Any thoughts on what needs to be done here? Maybe I need a second variable? 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,945 Most Valuable Professional on at
    Reset is triggered by a change of the Variable value - try this OnSelect
    UpdateContext({varResetSubLedgerReview: false});
    UpdateContext({varResetSubLedgerReview: true});
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     
  • futr_vision Profile Picture
    831 Moderator on at
    I've tried this before but the problem is, when these variables are set to true, the DefaultSelectedItems of the child combo box is set to Blank. When you submit the update, the value is not what you selected in the combo box but the blank value.
  • WarrenBelz Profile Picture
    154,945 Most Valuable Professional on at
    Sorry, but I am a bit unclear here
    When a parent combo box is changed I want the child combo box(es) to appear blank.
    If you are doing this OnChange of the Parent Combo
    UpdateContext({varResetSubLedgerReview: false});
    UpdateContext({varResetSubLedgerReview: true});
    it sets The Variable varResetSubLedgerReview to true and triggers two things
    The Reset of the child box and then 
    The Default Selected Items of the child is
    {Value:If(varResetSubLedgerReview,Blank(), Parent.Default)}
    which means it should display blank every time you select the parent control.
  • futr_vision Profile Picture
    831 Moderator on at
    Right, but when I change the value in the child combo box the variable is still true which means the value is blank. When I submit the blank is written to the table. What I find odd is that if I were to edit that same record again, the value I chose in the child combo box gets written to the table. Maybe because it is already blank? I'm not sure I understand exactly what is happening there.
  • futr_vision Profile Picture
    831 Moderator on at
    Or maybe it does work. It seems like PowerApps is finicky about these things. Sometimes things work and other times it fails. I am noticing another issue however. When a child combo box is required, even though there is a value there and that value is never touched, the submit fails because it is saying that combo box is required.
  • futr_vision Profile Picture
    831 Moderator on at
    I just reviewed the child combo box I've initially been working on and see what is happening. It is still broken. Here is what I experience.
    1. Change the parent and the child box becomes blank - 
    2. Seclect a new value in child combo box
    3. Submit
    4. All works well
    5. Edit a record that has a value for the child combo box
    6. Edit a different combo box or just resubmit
    7. A blank gets written to the record for the child combo box.
    I hope I explained the behavior. Not really sure what is happening there. There is nothing setting the variable to true that would trigger the reset of the child combo box. I dropped a label on the screen to see what the default is for the data card. It holds the expected value. I added a second label to see what the selected value for the combo box is and that is blank. This seems to be the same thing happening with the required combo box mentioned in my previous post. Thoughts?
  • futr_vision Profile Picture
    831 Moderator on at
    If I remove this code for DefaultSelectedItems, in the child combo box
     
    {Value:If(varResetSubLedgerReview,Blank(), Parent.Default)}
    and replace with
    {dk_subledgername: Parent.Default}
    This works but this obviously breaks the ability to blank out the child combo box.
     
    I tried replacing 
    {Value:If(varResetSubLedgerReview,Blank(), Parent.Default)}
    with
    {Value:If(varResetSubLedgerReview,Blank(), {dk_subledgername: Parent.Default})}
    but this just puts [object Object] in the child combo box
  • Suggested answer
    yonie Profile Picture
    35 on at
    I would do the following:
    1. In the OnSelect() from your Gallery
      Navigate(FormScreen,ScreenTransition.Fade, {SelectedGalleryItem: ThisItem});
      ResetForm(Form1);
      EditForm(Form1);
      2. In your form use the default item as follows
      SelectedGalleryItem
      3. Then assuming you have 3 comboboxes, set the OnChange() property to
      • Combobox1 (Grandparent)
        If(Self.Selected.Id <> SelectedGalleryItem.Combobox1.Id, 
        UpdateContext({SelectedGalleryItem: Patch(SelectedGalleryItem, {Combobox1: Self.Selected, Combobox2: Blank(), Combobox3: Blank()})});
        Reset(ComboBox2); Reset(ComboBox3))
         
      • Combobox2 (Parent)
        If(Self.Selected.Id <> SelectedGalleryItem.Combobox2.Id, 
        UpdateContext({SelectedGalleryItem: Patch(SelectedGalleryItem, {Combobox2: Self.Selected, Combobox3: Blank()})});
        Reset(ComboBox3))
         
      • Combobox3 (Child)
        Nothing
         
      4. In your datacard you should set that the value is required, when submitting the form it'll check if it has a value.
       
  • futr_vision Profile Picture
    831 Moderator on at
    @yonie. 
     
    I haven't done exactly what you are saying but I've tried to leverage OnChange. Problem is that whenever you select a new record it triggers the OnChange. Not sure if that will affect your code or not but I wanted to point that out. 
  • futr_vision Profile Picture
    831 Moderator on at
    @yonie
     
    Once I add the code to the grandparent combo box I get this error
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard