web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : lr9LAenN4kyVnw6OKvbbVF
Power Apps - Building Power Apps
Unanswered

Filtered combobox - default

Like (0) ShareShare
ReportReport
Posted on 25 Nov 2021 11:42:02 by 289

Hi Guys,

 

I have an app which includes a gallery where a user can select a number of products. On each gallery item there are 2 combo boxes, let's call them cmb_1 and cmb_2.   cmb_1 acts as a filter for cmb_2. A product hierarchy if you like.

 

After I have saved the first product it patches to a collection, when I then go back and change cmb_1 I would like to clear the contents of cmb_2 but I can't get it working.

 

The default selected items property of cmb_2 is: 

 

{Value:ThisItem.ProductCategory}

 

 

So it will take the value of whatever is in the collection and I can't get it to clear. This means a user could potentially save an invalid product combination.

 

I tried to reset it by adding the following code to the on change of cmb_1:

 

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

 

 

And then the following code to the reset  of cmb_2:

 

varReset

 

 

This does work if I haven't patched the record to the collection but after I patch it cmb_2 value won't clear. 

 

I understand why it's happening, just not sure how to fix it.

Categories:
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on 11 Dec 2021 at 00:49:57
    Re: Filtered combobox - default

    Hi @JimJim 


    Please let us know if anything needs on your post. We can help with this.

    Please mark the post as Solved If I have answered your question.
    Please give it a Thumbs Up if you find the suggestion helpful

    Thanks,
    Stalin - Learn To Illuminate

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on 27 Nov 2021 at 01:07:57
    Re: Filtered combobox - default

    Hi @JimJim 

     

    You can have a dummy ID if you want like GUID and check the length when saving the record. The length is 32 means a new record.

     

    StalinPonnusamy_0-1637975076794.png

     

    Another option is to have ID as GUID and another field for Flag (Boolean) for new records. So that when you are saving the record check that flag. If it's true it means new.

     

    In this case, you can use SP ID (Numeric) and the GUID for any data manipulation.


    Thanks,
    Stalin - Learn To Illuminate

  • JimJim Profile Picture
    289 on 26 Nov 2021 at 08:38:58
    Re: Filtered combobox - default

    Hi @StalinPonnusamy ,

    Thank you for replying, but this doesn't work unfortunately.

    The ID will never exist in the collection until it writes to the SP list, it does this on the OnSuccess of the form (I should have made this clearer)

    I think my best option here is to replace the combo boxes with drop downs as they behave differently

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on 26 Nov 2021 at 06:22:07
    Re: Filtered combobox - default

    Hi @JimJim 

     

    Will try another approach.

     

    Set the OnChange property of Combo 1 to

    If(Not(ThisItem.ID in ColItemSelected),Collect(ColItemSelected, {ID:ThisItem.ID}))

     

    Set the DefaultSelected property of Combo 2 to

    If(ThisItem.ID in ColItemSelected.ID, {Value : Blank() },{Value: ThisItem.ProductCategory})

     

    Set OnSelect property of Save or Patch to

    Clear(ColItemSelected)

     


    Thanks,
    Stalin - Learn To Illuminate

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

Announcing our 2025 Season 2 Super Users!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2