cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jobb89
Frequent Visitor

DefaultSelectedItems in Combobox displaying data correctly but table filtered on combobox results does not show default values, only manually selected items

Hello,

 

I was hoping to get some help with a combobox and the DefaultSelectedItems property. From my reading of quite a few other posts, it seems that the DefaultSelectedItems for a combobox can display the correct default items for that combobox, but when trying to display more detailed information about the lookup items in a table, the default selected values are not displayed in this table.

 

To provide more information about the set up. I have a gallery displaying summarised data from a list called space allocation. In this space allocation list is a multi-select lookup column to a personnel list. This is so that you can say 'this person is assigned to this workspace, or these two people share this workspace' as an example, and the person(s) assigned to the workspace are the personnel records from the lookup list. It should display the people already assigned to this location, but it should also allow users to add new people to this space by searching the personnel list.

 

I have created a gallery which has personnel lookup column values shown in the gallery using a combobox. There is a button for the gallery item which says 'view all details', and this will navigate the user to a new screen with an edit form. In this edit form is another combobox which also displays the personnel lookup data.

 

Gallery Combobox properties:

DefaultSelectedItems - ThisItem.PersonnelIdentifier

Items - SortByColumns(Filter('Personnel List',StartsWith(Identifier,Self.SearchText)),"Identifier")

 

Edit Form Combobox properties (called Personnel_SpaceAllocationDetails_Combobox):

DefaultSelectedItems - ThisItem.PersonnelIdentifier

Items - SortByColumns(Filter('Personnel List',StartsWith(Identifier,Self.SearchText)),"Identifier")

 

When in the Edit Form section, the table that displays the detailed data from the personnel list has this set as the Items property:

 

Filter(
    'Personnel List',
    Or(
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,1)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,2)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,3)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,4)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,5)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,6)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,7)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,8)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,9)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,10)).PersonnelIdentifier,
        PersonnelIdentifier = Last(FirstN(Personnel_SpaceAllocationDetails_ComboBox.SelectedItems,11)).PersonnelIdentifier
))

 

The personnel list has >5000 records, and that's why I used self.search in the combobox lookup function.

 

Now the issue I am having is that both the gallery and edit form comboboxes will display the already assigned people without an issue. However, the table, which is displaying the selected items from the Edit Form combobox, will NOT display any results even if there were people already assigned here. If you select new people in the combobox, they will display in the table straight away. If you remove the previously assigned person from the combobox and then manually select them again, they will also display in the table.

 

From my reading the issue seems to be that DefaultSelectedItems will 'load' the default items, but will not 'select' them (Solved: ComboBox DefaultSelectedItems functionality - Power Platform Community (microsoft.com)). Some people say that the DefaultSelectedItems and Items properties should be equivalent and this will also fix the issue, but I can't see a good way to do this or the approach from the linked post.

 

Any assistance would be appreciated, thank you!

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi @jobb89 ,

Firstly, you might try this on your gallery filter - the only Data Row Limit restriction here is on the output which I assume will be fairly small.

Sort(
   Ungroup(
      ForAll(
         Personnel_SpaceAllocationDetails_ComboBox.SelectedItems As _Data,
         Filter(
            'Personnel List',
            PersonnelIdentifier = _Data.PersonnelIdentifier
         )
      ),
      "Value",
   ),
   PersonnelIdentifier
)

As to your DefaultSelectedItems, the Personnel_SpaceAllocationDetails_Combobox would be

{PersonnelIdentifier: ThisItem.PersonnelIdentifier}

so the first part is the field name displayed (.Selected.xxxx) in the Combo Box and the second the field content you want displayed.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

MVP (Business Applications)   Visit my blog Practical Power Apps

View solution in original post

@jobb89 The problem is that while DefaultSelectedItems may load default items correctly, it might not effectively select them in a way that updates the associated table.

 

You can try a different approach to ensure the selected items are properly reflected in the table. Instead of relying on DefaultSelectedItems, you can dynamically set the selected items using the OnVisible property of the screen or any other appropriate trigger.

 

In the ComboBox OnVisible property, Enter : 

Set(Personnel_SelectedItems, ThisItem.PersonnelIdentifier)

That will store the initial selected items in a variable (Personnel_SelectedItems).

 

Update the DefaultSelectedItems property of your ComboBox in the edit form to use this variable:

DefaultSelectedItems = Personnel_SelectedItems

 

Also modify the Items property of the table to use the variable:

Filter(
   'Personnel List',
   Or(
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,1)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,2)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,3)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,4)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,5)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,6)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,7)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,8)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,9)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,10)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,11)).PersonnelIdentifier
   )
)

 

If this solves your question, please accept it as a solution.

Thanks!

Dallas

View solution in original post

5 REPLIES 5
WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi @jobb89 ,

Firstly, you might try this on your gallery filter - the only Data Row Limit restriction here is on the output which I assume will be fairly small.

Sort(
   Ungroup(
      ForAll(
         Personnel_SpaceAllocationDetails_ComboBox.SelectedItems As _Data,
         Filter(
            'Personnel List',
            PersonnelIdentifier = _Data.PersonnelIdentifier
         )
      ),
      "Value",
   ),
   PersonnelIdentifier
)

As to your DefaultSelectedItems, the Personnel_SpaceAllocationDetails_Combobox would be

{PersonnelIdentifier: ThisItem.PersonnelIdentifier}

so the first part is the field name displayed (.Selected.xxxx) in the Combo Box and the second the field content you want displayed.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

MVP (Business Applications)   Visit my blog Practical Power Apps

@jobb89 The problem is that while DefaultSelectedItems may load default items correctly, it might not effectively select them in a way that updates the associated table.

 

You can try a different approach to ensure the selected items are properly reflected in the table. Instead of relying on DefaultSelectedItems, you can dynamically set the selected items using the OnVisible property of the screen or any other appropriate trigger.

 

In the ComboBox OnVisible property, Enter : 

Set(Personnel_SelectedItems, ThisItem.PersonnelIdentifier)

That will store the initial selected items in a variable (Personnel_SelectedItems).

 

Update the DefaultSelectedItems property of your ComboBox in the edit form to use this variable:

DefaultSelectedItems = Personnel_SelectedItems

 

Also modify the Items property of the table to use the variable:

Filter(
   'Personnel List',
   Or(
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,1)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,2)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,3)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,4)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,5)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,6)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,7)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,8)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,9)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,10)).PersonnelIdentifier,
      PersonnelIdentifier = Last(FirstN(Personnel_SelectedItems,11)).PersonnelIdentifier
   )
)

 

If this solves your question, please accept it as a solution.

Thanks!

Dallas

jobb89
Frequent Visitor

Hello Dallas and WarrenBelz, thanks for your responses. I tried Warren's solution first as it seemed to be the quickest to test, and it worked! Thank you, much appreciated. I will look at your solution as well Warren, to try and learn from it. 

WarrenBelz
Most Valuable Professional
Most Valuable Professional

Hi@jobb89 ,

If mine worked for you please mark that as well as future users need to be able to find it.
In particular, the alternate Items are much more efficient (it only queries the ones selected) and also a Variable does nothing different to what I posted than add an extra step and leave a "one use" Variable in the app, which can have a cumulative affect on performance (though there needs to be a lot of them for this to be relevant).

Hi Warren,

 

I tried your solution, but am having a bit of trouble getting it to work. With the Sort and Ungroup formula, is this supposed to be on the data table that displays the combobox values?

 

As for the defaultselecteditems, I tried 

 

 

 

{PersonnelIdentifier: ThisItem.PersonnelIdentifier}

 

 

 

It ends up showing nothing in either the combobox or the data table.

 

I tried adding a drop-down menu whose items property was Personnel_SpaceAllocationDetails_ComboBox.SelectedItems, and the dropdown menu options will populate with the correct combobox default values. However, if I also set the data table properties to Personnel_SpaceAllocationDetails_ComboBox.SelectedItems, it will have x number of blank rows, were x is the number of default values in the combobox. If I manually select an additional combobox option, it will then display the correct information in the data table. I don't really understand how a dropdown control can recognise the defaultselecteditems of the combobox, but the data table only recognises the manually added options. Interestingly, if I have say 4 default selections, the drop-down will have these 4 values appropriately, and the data table has 4 blank rows. If I add 1 manual selection, then the dropdown shows 4 options and an additional blank option, whereas the data table will show 4 blank rows and then 1 correct row.

 

I also tried to mimic the combobox defaultselecteditems property with the same data source as is used in the items property. So instead of ThisItem.PersonnelIdentifier, it would be:

ForAll(ThisItem.PersonnelIdentifier,Filter( Personnel List, PersonnelIdentifier = ThisRecord.PersonnelIdentifier)). This will then say error when trying to retrieve data from the network, which is presumably because there are >5000 records. If I change it to mimic the combobox items lookup:

 

 

ForAll(ThisItem.PersonnelIdentifier,Filter( Personnel List, StartsWith(PersonnelIdentifier, ThisRecord.PersonnelIdentifier)))

 

It recognises there are the correct number of default values, but the display fields are [object object] in both the combobox and the dropdown which is using the combobox selected items as its items property. The data table still is blank

 

 

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (812)