cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
VickyW
Level: Powered On

DefaultSelectedItems and Item property in conflict

Hi All

 

Hopefully someone can help me with some formulas

I have 3 ComboBoxes on my form with formulas in the ITEM propery to filter/sort the available cBox options:

 

1. The 'Supplier' cBox has this formula to filters to distinct results only:

Distinct('[dbo].[SupplierServices]',Supplier)

 2. The 'Goods/Service cBox has a formula to filter results by what's in the first cBox

Filter('[dbo].[SupplierServices]',Supplier=ComboBox1.Selected.Result)

3. The Employee cBox has a formula to sort the employee names into alphabetical

Sort('[dbo].[StaffRegister]'.InitialSurname,InitialSurname)

But....
The problem is if I paste these formulas into the ComboBox ITEM properties it breaks my DefaultSelectedItems?

And I need the DefaultSelectedItems, so that when the user goes back to edit a record, their previous selection is still there, otherwise they would have to select all 3 again before saving

Am I placing these formulas in the wrong place?

I can believe MS would make you chose between having a DefaultItemsSelected or sorting/filtering would they?

Any advice would be appreciated

Regards

Vicky

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Level 10

Re: DefaultSelectedItems and Item property in conflict

@VickyW

 

The first is wrong. 

On FirstCombo.Items do this:

Distinct(MyTable,MyGroupName).Result

This wil return a one column table off text values.

 

The DefaultSelectedItems is a little strange. You should say this should be just the textstring, but this didn't seem to work. So I tried something else and this worked. So do on FirstCombo.DefaultSelectedItems

LookUp(Distinct(MyTable,MyGroupName).Result, Result = "MySearchString")

 

The second one should then work, because the first is fixed and the ComboBox1.Selected.Result will give a value for the condition part off the Filter(). Then you do a lookUp() for the DefaultSelectedItems, same as on the third.

 

Hope this helps.

 

Paul

View solution in original post

4 REPLIES 4
VickyW
Level: Powered On

Re: DefaultSelectedItems and Item property in conflict

ComboBox 3 is now sorted, thanks to @KroonOfficeSol suggestion in my old post
J
ust 1 and 2 that are still problematic

KroonOfficeSol
Level 10

Re: DefaultSelectedItems and Item property in conflict

@VickyW

 

The first is wrong. 

On FirstCombo.Items do this:

Distinct(MyTable,MyGroupName).Result

This wil return a one column table off text values.

 

The DefaultSelectedItems is a little strange. You should say this should be just the textstring, but this didn't seem to work. So I tried something else and this worked. So do on FirstCombo.DefaultSelectedItems

LookUp(Distinct(MyTable,MyGroupName).Result, Result = "MySearchString")

 

The second one should then work, because the first is fixed and the ComboBox1.Selected.Result will give a value for the condition part off the Filter(). Then you do a lookUp() for the DefaultSelectedItems, same as on the third.

 

Hope this helps.

 

Paul

View solution in original post

VickyW
Level: Powered On

Re: DefaultSelectedItems and Item property in conflict

@KroonOfficeSol I can't thank you enough!
I was starting to worry that I'd be showing the boss a very janky app come Monday
But all 3 ComboBoxes are working beautifully now, with the formulas to sort/filter! Smiley Very Happy

The only thing left that I'd like to do (and it's not the end of the world if I can't) is put an IF statement on that Employee combo DefaultSelectedItems

If the form is in edit mode, get the employee name on that row of the MobilePOLog table: 

If(EditForm1.Mode in [0,2], LookUp('[dbo].[MobilePOLog]', PONumber = ThisItem.PONumber))

Else if the form is in new mode, use the current users email address to look up their name on the StaffRegister table:

LookUp('[dbo].[StaffRegister]',Email = User().Email, Employee)

But when I put them together it doesn't work

If(EditForm1.Mode in [0,2], LookUp('[dbo].[MobilePOLog]', PONumber = ThisItem.PONumber),
LookUp('[dbo].[StaffRegister]',Email = User().Email, Employee))


Thanks again, even without this bit you have already saved my bacon!
V

 

 

KroonOfficeSol
Level 10

Re: DefaultSelectedItems and Item property in conflict

@VickyW

 

You are using another entity than you do in the items, so no wonder if it doesn't work.

 

Maybe you could try to do this at the Combo.Items attribute:

If(EditForm1.Mode in [0,2], ShowColumns('[dbo].[MobilePOLog]', "EmployeeName"),
ShowColumns('[dbo].[StaffRegister]', "EmployeeName"))

I wouldn't know if the combo digs the switch in datasource without issues, so just try.

This will work when the "Employee" is the samen. If not then you maybe also should change the Datacard.Update attribute. Lets say the first gives back a field/attribute called PersonName then use like this:

If(EditForm1.Mode in [0,2], "PersonName", "EmployeeName")

In this case I presumed your datacard need text for the update. If this is different you should tweak it a little bit.

 

Hope this helps.

 

Paul

Helpful resources

Announcements
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 (5,575)