cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
v-micsh-msft
Community Support
Community Support

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
v-micsh-msft
Community Support
Community Support

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

Hi @Anonymous,

 

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.

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (93,553)