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

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
Highlighted
Community Support
Community Support

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
Highlighted
Community Support
Community Support

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

Highlighted
Community Support
Community Support

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.
Highlighted
Kudo Collector
Kudo Collector

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
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,636)