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

Set default selected item based on current user

Hi all,

 

I have SharePoint list called Employees and it contain below field;( these field are single line  text and import from datavers using power automate. )

  1. Full name
  2. Email
  3. Division
  4. Operating Unit
  5. Approver name
  6. Approver Email

In canvas app, there are two drop down list called, opUnit(dropdown), Approver(dropdown)

Each dropdown list

opUnit ‘Items’ →District(‘Employees’, ‘Operation Unit’

Approver ‘items’ →District(‘Employees’, ‘Approver Name’

 

And I want to set their default selected item based on current user. 
Ex: if current user equal to Full name, then it’s related values populate in drop down lists.

 

I tried someway but it didn’t worked properly. Hope your support.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @ShriniA,

Okay, so it is a canvas app for Teams, right?

You mean the options display correct, however it displays nothing within the Combo Box, right?

 

Try to select the edit icon on the right pane of the fields, select the Result field name for the Combo Box.

vqiaqimsft_0-1662539103596.png

Then you should modify your formula as below:

Filter(Distinct(Employees,‘Operation Unit’),Result=LookUp('KIT2.0_HR Data',Lower(currentuser)='Emailxxxx').‘Operation Unit’)

Modify your Filter() function as LookUp() function but keep the content within.

 

The key to this issue is that you set the Items property with a Result column table returned by Distinct() function, so you need to filter within the Result table rather than your data source.

 

 

Best Regards,
Qi

View solution in original post

10 REPLIES 10
phipps0218
Super User
Super User

You can use User().FullName or User().Email to get the logged in user.

NandiniBhagya20
Solution Sage
Solution Sage

Hi,

If you have a drop down then you can use below formula in Default property of Operation Unit
LookUp(Employees, Lower(Email) = Lower(User().Email), 'Operating Unit')

I would suggest you to go for email


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

@NandiniBhagya20 

I got error in this formula.

I used LookUp(Employees, Lower(emailaddress) = Lower(User().Email),’Operating Unit’)

 

This emailaddress is column name of Employees table Email.

v-qiaqi-msft
Community Support
Community Support

Hi @ShriniA,

Do you want to populate the Combo Box with corresponding user if the current user has the same full name with it exists in the Full Name column?

 

The DefaultSelectedItems property expect table value, so you should set it as below:

Filter('Employees',User().FullName='Full Name').'Operation Unit'
Filter('Employees',User().FullName='Full Name').'Approver Name'
Best Regards,
Qi

@v-qiaqi-msft ,

Your query is worked but it doesn’t appear in dropdown field. I have no idea why it’s not appear in dropdown field.I checked it and get correct value. 

Hi @ShriniA,

Could you please provide some screenshots to describe your scenario?

Where do you have theses Combo Boxes and how you set the Item property of them?

 

Please do provide some detailed screenshots about controls or anything else makes sense.

Best Regards,
Qi

Here is the screenshot. 

36EC4918-95E0-4EDA-898A-87B35652CB59.jpeg

items →District(‘Employees’, ‘Operation Unit’)
Dropdown list have correct items when apps play.

Hi @ShriniA,

Okay, so it is a canvas app for Teams, right?

You mean the options display correct, however it displays nothing within the Combo Box, right?

 

Try to select the edit icon on the right pane of the fields, select the Result field name for the Combo Box.

vqiaqimsft_0-1662539103596.png

Then you should modify your formula as below:

Filter(Distinct(Employees,‘Operation Unit’),Result=LookUp('KIT2.0_HR Data',Lower(currentuser)='Emailxxxx').‘Operation Unit’)

Modify your Filter() function as LookUp() function but keep the content within.

 

The key to this issue is that you set the Items property with a Result column table returned by Distinct() function, so you need to filter within the Result table rather than your data source.

 

 

Best Regards,
Qi

@v-qiaqi-msft 

Thank you. It works perfectly.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,139)