Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    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 at
    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 at
    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 at
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,522 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,890 Most Valuable Professional

Leaderboard