cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mary_ann
Helper I
Helper I

Set DefaultSelectedItem and Items in combobox from 2 different table

Hi everyone,


I have a form in which there is one combobox so i want to update the name. I want to use only one combobox here. Now on Collection named "ModifyProject" I have one single row and name is in column "project_lead", so by default in defaultselecteditem property in combobox it should show the name. And in items property it should have list of all the name from database.

So this is what I have did:
In Items Property: 

'[dbo].[AzureADGroupsTable]'

I have wrote this and selected Field as name. Here I am getting all the results. No issue here.

In DefaultSelectedItems Property:

ModifyProject.project_lead

In here I am taking the name directly from the Collection ModifyProject.  As you can see img 3, it shows nothing, not even throwing error.

Please help , Here i want defaultselectedItem should have name. It shows nothing right now.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@mary_ann 

The DefaultSelectedItems property (DSI) of a Combobox expects a Record or Table of Records (depending on the settings of the combobox).  

The Record schema of the provided record MUST match the schema of the Items property.

 

In your case you are setting the Items to an entire table - which will be a table of records with a schema based on the schema of [dso].[AzureADGroupsTable].

Then your DSI is set to a table with a single column schema with each column, most likely, containing a text value.  This will never match!  It will give you an error but it will not match.

 

I do not know what dependencies you have on the Combobox selected items, but if you are ONLY utilizing the displayname column values, consider changing your Items property to:    

ShowColumns('[dbo].[AzureADGroupsTable]', "displayname")

 

Now, for your DSI property...you need to reference a single record in your ModifyProject table.  Currently you are referencing the entire table and thus you will get an entire table, which again will not match.

So, once you determine how you will get to a single record in that table based on your App (I'd recommend approaches, but I do not know your scenario at this point) then you can use that in the DSI.

   {displayname: yoursingleprojectrecord.project_lead}

The above will give you a proper selection in the combobox.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@mary_ann 

The DefaultSelectedItems property (DSI) of a Combobox expects a Record or Table of Records (depending on the settings of the combobox).  

The Record schema of the provided record MUST match the schema of the Items property.

 

In your case you are setting the Items to an entire table - which will be a table of records with a schema based on the schema of [dso].[AzureADGroupsTable].

Then your DSI is set to a table with a single column schema with each column, most likely, containing a text value.  This will never match!  It will give you an error but it will not match.

 

I do not know what dependencies you have on the Combobox selected items, but if you are ONLY utilizing the displayname column values, consider changing your Items property to:    

ShowColumns('[dbo].[AzureADGroupsTable]', "displayname")

 

Now, for your DSI property...you need to reference a single record in your ModifyProject table.  Currently you are referencing the entire table and thus you will get an entire table, which again will not match.

So, once you determine how you will get to a single record in that table based on your App (I'd recommend approaches, but I do not know your scenario at this point) then you can use that in the DSI.

   {displayname: yoursingleprojectrecord.project_lead}

The above will give you a proper selection in the combobox.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Thank you so much. You saved my day 🙂

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,217)