Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Set default selected item based on current user

Posted on by

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.

  • ShriniA Profile Picture
    ShriniA on at
    Re: Set default selected item based on current user

    I need help below scenario.

    I get Employees data from dataverse by using power automate. Approver Name is not a display name in office 365 account. It’s just last name and first name. But I have Approver Email address which is match to office 365 account. My question is, how to get user display name by Approver email?

     

  • ShriniA Profile Picture
    ShriniA on at
    Re: Set default selected item based on current user

    @v-qiaqi-msft 

    Thank you. It works perfectly.

  • Verified answer
    Re: Set default selected item based on current user

    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.

     

     

  • ShriniA Profile Picture
    ShriniA on at
    Re: Set default selected item based on current user

    Here is the screenshot. 

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

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

  • Re: Set default selected item based on current user

    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.

  • ShriniA Profile Picture
    ShriniA on at
    Re: Set default selected item based on current user

    @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. 

  • Re: Set default selected item based on current user

    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'
  • ShriniA Profile Picture
    ShriniA on at
    Re: Set default selected item based on current user

    @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.

  • NandiniBhagya20 Profile Picture
    NandiniBhagya20 4,650 on at
    Re: Set default selected item based on current user

    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

  • phipps0218 Profile Picture
    phipps0218 on at
    Re: Set default selected item based on current user

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard