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 / Filtered combobox - de...
Power Apps
Unanswered

Filtered combobox - default

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    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

  • JimJim Profile Picture
    289 on at

    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 at

    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

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    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

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard