cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Gargoolgala
Level 8

Dropdown remove selected items

Hi - I am attempting to remove selected items based on a change in another dropdown.

 

My defaults are to lookup the sharepoint list record and I am using a multiple choice dropdown to show the value of the record.  This is working fine e.g. I open a record and I see the correct values.

 

I have 2 dropdowns - 1 for Operating System and another is only visible if a specific item is selected in dropdown 1 which is a subset of operating systems. e.g. If  Ichoose Windows in dropdown 1 then dropdown 2 appears and I get to select the Win O/S - Win 2003 / win 2008 / win 2012 etc.

 

If I deselect Windows in dropdown 1 I need to remove any selections from dropdown 2 - the problem is dropdown 2 is set to the value in the sharepoint list by default which still holds the previously selected value and when I save it it will keep that value.

 

I want  to de-select the selected items so when I save it will update the record appropriately.

 

THis is fine if it was a once off creation / save as if I have not saved the record then the default is blank - it is a problem when I come back in to edit though.

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Gargoolgala
Level 8

Re: Dropdown remove selected items

OK - I managed to solve this in a round about way.

 

If("Windows" in dcvServerOS.SelectedItems.Value,false,Patch('Secure Print Assessments',First(Filter('Secure Print Assessments', ID=CustomerTable.Selected.ID)),{ServerOS:dcvServerOS.SelectedItems.Value,WindowsServerOS:lbTest.SelectedItems.Value}))

 

I created a fake listbox lbTest which will be invisible and I will never select anything from - it seems I need to update a multichoice dropdown with a table value not a text value.  A listbox will give me this - I think I also needed to populate it with 1 list item which I will never select.

 

I put this on my onchange and patch the sharepoint list on the fly if  Ideselect an item which then updates teh selected items approriately and other controls will then be visible based on other dropdown vales.

 

Also needed to make sure I had a true and a false condition on the visibilty of some controls as I only had a true so at times I would still see a control I should not be - but this was just a logic thing.

 

Now if I could do all of this with multi choice listboxes instead of only dropdowns it would be much better but that is for another feature  Iwill need to push on 🙂

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Dropdown remove selected items

Hi @Gargoolgala,

 

Could you please share more details about how you save the record, within an EditForm control, or just use the patch() function?

Different approaches may need to configure different properties.

For example, if here you are using the EditForm control, then for the Drodpown 2 DataCard,, there should be Update property for this field, based on the description, the recommended formula should be:

If(Dropdown1.Selected.Value in ["Windows","Value2" ], Dropdown2.Selected.Value, "") 

Or we could check the condition based on the Visible property of Dropdown2, formula should be changed to:

If(Dropdown2.Visible,Dropdown2.Selected.Value,"")

 

If here you use the patch() function, if would be much helpful if you could share the formula you used, so that I could suggest the modification accordingly.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Gargoolgala
Level 8

Re: Dropdown remove selected items

Michael,

 

I have tried this for the OnChange for dropdown1 (dcvServerOS)

 

If("Windows" in dcvServerOS.SelectedItems.Value,false,Patch('Secure Print Assessments',First(Filter('Secure Print Assessments', ID=CustomerTable.Selected.ID)),{WindowsServerOS:""}))

 

I was hoping to patch only the one value - basically reset it.  Problem is that {WindowsServerOS:""} is invalid.

 

I also tried If("Windows" in dcvServerOS.SelectedItems.Value,false,Patch('Secure Print Assessments',First(Filter('Secure Print Assessments', ID=CustomerTable.Selected.ID)),{WindowsServerOS:lbTest.SelectedItems.Value})) - lbtest is just an empty listbox - that did not patch an empty value.

 

If I use your option of on visibile or not  Iget the same error that I get in that the table value does not match the text value - invalid data type.  I think this is to do with the "" as it is just an empty text value. Thats why I tried the lbTest.selectedItems option which removes the error but still does not update the value correctly.

 

The reason I need to do it on the fly with onchange is because the values in the second dropdown also determine the visibility of other controls.

 

 

Gargoolgala
Level 8

Re: Dropdown remove selected items

OK - I managed to solve this in a round about way.

 

If("Windows" in dcvServerOS.SelectedItems.Value,false,Patch('Secure Print Assessments',First(Filter('Secure Print Assessments', ID=CustomerTable.Selected.ID)),{ServerOS:dcvServerOS.SelectedItems.Value,WindowsServerOS:lbTest.SelectedItems.Value}))

 

I created a fake listbox lbTest which will be invisible and I will never select anything from - it seems I need to update a multichoice dropdown with a table value not a text value.  A listbox will give me this - I think I also needed to populate it with 1 list item which I will never select.

 

I put this on my onchange and patch the sharepoint list on the fly if  Ideselect an item which then updates teh selected items approriately and other controls will then be visible based on other dropdown vales.

 

Also needed to make sure I had a true and a false condition on the visibilty of some controls as I only had a true so at times I would still see a control I should not be - but this was just a logic thing.

 

Now if I could do all of this with multi choice listboxes instead of only dropdowns it would be much better but that is for another feature  Iwill need to push on 🙂

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,583)