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

Change data source for a drop down on the basis of label text

Hi,

 

I have a drop down which consists the list of sub ordinates and I want to change its value on the basis of manager who logs in

 

So I have written a code for a "Drop Down" in its item field to change the source data (table) depending on the value of "Label1" which returns the name of the person who logs in

 

If(Label1.Text="Tom Stuart",Table1,Table3)

 

(i.e if Tom Stuart logs in then drop down should display list as per Table 1 else Table 3, I also want to convert this code into multiple if statement as there is a big list of managers and their subordinates)

 

But the above code gives me an error with a info sign that "columns produced by this rule are nested tables/records, however property expects atleast some simple values (such as text or numbers)"

 

Please assist with a correct code to resolve this error.

 

One more ques? let me know if there is a code to get subordinates list from outlook.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Change data source for a drop down on the basis of label text

If you would like to switch Data Source for the Dropdown Control, the available way is to use Lookup() function.

First we need to save the Table within a collection.

Add a Button, enter the following code for the TableCollection under the OnSelect property, or you may put it under the Screen OnVisible property:

ClearCollect(TableCollection, 
Table({UserName:"UserFullName1",Table:Table1},
{UserName:"UserFullName2",Table:Table3})
)
ClearCollect(Userstring,User())

For User logs in, the formula for the items property of the Dropdown should be:

Lookup(TableCollection, UserName=First(Userstring).FullName, Table)

To get the Manager of current user, we could take use of Office 365 Users connection.

Also you could take use of the Office365Users.DirectReports() to get the direct reports for the specified user.

More information, see the documentation:

Connect to Office 365 Users connection from PowerApps

 

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.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Change data source for a drop down on the basis of label text

If you would like to switch Data Source for the Dropdown Control, the available way is to use Lookup() function.

First we need to save the Table within a collection.

Add a Button, enter the following code for the TableCollection under the OnSelect property, or you may put it under the Screen OnVisible property:

ClearCollect(TableCollection, 
Table({UserName:"UserFullName1",Table:Table1},
{UserName:"UserFullName2",Table:Table3})
)
ClearCollect(Userstring,User())

For User logs in, the formula for the items property of the Dropdown should be:

Lookup(TableCollection, UserName=First(Userstring).FullName, Table)

To get the Manager of current user, we could take use of Office 365 Users connection.

Also you could take use of the Office365Users.DirectReports() to get the direct reports for the specified user.

More information, see the documentation:

Connect to Office 365 Users connection from PowerApps

 

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.

View solution in original post

Community Support Team
Community Support Team

Re: Change data source for a drop down on the basis of label text

Hi @Ankur,

 

Do you need any further help on this?

 

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.
clau0289
Level: Powered On

Re: Change data source for a drop down on the basis of label text

Hello Michael,

 

I was looking for something like this but I have found a couple of barriers I cannot jump...

What If you had to chage some data in the TableCollection that should be also reported in its corrispondant Table1 or Table2... etc?

How would you manage attachments?

 

I am facing this problem not with simple tables but with sharepoint lists with attachments and I can't get around this to find a solution. Any ideas?

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

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