Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Auto populate person type column with logged in user

(0) ShareShare
ReportReport
Posted on by 3

I want to auto-populate my Person type drop down with current logged in user. I went over the other threads for the same scenario and tried using - Office365Users.MyProfile() also Office365Users.MyProfileV2() but it is not populating any values in the dropdown.

 

Thanks!

  • gstlouis Profile Picture
    on at
    Re: Auto populate person type column with logged in user

    for me this solution does not work.  IF I use 

     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims: "i:0#.f|membership|"&User().Email,
     DisplayName: User().FullName
     }

    I get Network error when using Patch function: The requested operation is invalid

  • gstlouis Profile Picture
    on at
    Re: Auto populate person type column with logged in user

    Thanks for sharing.  But how would have someone figured this out?  It makes no sense and there is no explanation.  Can you share what resources you used to understand this?

  • hyperbob0811 Profile Picture
    91 on at
    anksRe: Auto populate person type column with logged in user

    Thank you I finally found something which worked.

  • TheSlawekG Profile Picture
    119 on at
    Re: Auto populate person type column with logged in user

    Thank you!

     

    I've tried a few solutions from this website and blogs and none of them was working but your!

     

    Regards,

     

    Slawek

  • Verified answer
    v-xida-msft Profile Picture
    on at
    Re: Auto populate person type column with logged in user

    Hi @arpan_mehetre,

     

    Do you add a SP list as a data source within your app?

    Do you want to auto-populate the Person type column with current login user when you open a New form (add a new record) within your app?

     

    I think it is not necessary to add a Office 365 Users connector within your app, the User function could achieve your needs.

     

    I have made a test on my side, please take a try with the following workaround:5.JPG

     

     

    • Unlock the Data card control which contains the Person type column.
    • Set the DefaultSelectedItems property of the Combo box control to following formula:
    If(
     EditForm1.Mode=FormMode.New,
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims: "i:0#.f|membership|"&User().Email,
     DisplayName: User().FullName
     },
     Parent.Default
    )

    More details about the User function in PowerApps, please check the following article:

    User function

     

    In addition, if the Person type column in your SP list allowes multiple values, please take a try with the second solution @RusselThomas mentioned.

     

     

    Best regards,

    Kris

  • RusselThomas Profile Picture
    4,012 on at
    Re: Auto populate person type column with logged in user

    hi @arpan_mehetre,

     

    Check out this blog by Carlos, should have all the answers you need.

    Specifically, the person column section as follows;

     

    Person columns

    The idea for setting defaults in Person is similar to the other column types, but for person you need to specify one field that uniquely identifies the user within the Office 365 (and Active Directory) tenant that hosts the SharePoint list - you can have two people with the same name, so that should not be an option. What is used in this case is the 'Claims' property of the person object, which has a not-very-user-friendly format. I've found that the best way to figure out the value that you need to use is to add a label control whose Text property shows the value of that Claims for the selected person:

    Retrieving the value for the Claims property

    This format shown above is common for most Person objects in SharePoint, so if you want to set the logged in user as the default value for a Person column, you would use the following expression:

    If(
     EditForm1.Mode = FormMode.New,
     {
     DisplayName: myself.FullName,
     Claims: "i:0#.f|membership|" & myself.Email
     },
     Parent.Default)

    Where myself is defined in the OnVisible property of the screen (or in the OnStart property of the app) as

    Set(myself, User())

    Notice that there are a few domains where the value of User().Email does not correspond to the user's e-mail (in tenants where the e-mail and the UPN are different), so if this is your case, you can use the Office 365 Users connection with the MyProfileV2 function.

    Another issue to be aware: some Person objects also support the usage of groups:

    Allow selection of groups in a Person column

    In this case, the common pattern of creating the Claims value based on the e-mail will likely not work, so you'll need to see what is the claims for the group you want to set as a default selection (for example, using the technique shown above to find the pattern) to get the value that is needed for the Claims property.

    For Person columns with multiple selection the process is similar, but you need to use a table instead of a single record. If you want to set the default value for the user and their manager, then you can use the Office 365 Users connector to retrieve it: in the initialization (screen's OnVisible or app's OnStart) you'd have this expression:

    Set(myself, Office365Users.MyProfileV2());
    Set(manager, Office365Users.Manager(myself.id))

    And on the DefaultSelectedItems for the combo box control, you can use this expression:

    If(
     EditForm1.Mode = FormMode.New,
     Filter(
     Table(
     {
     DisplayName: myself.displayName,
     Claims: "i:0#.f|membership|" & myself.mail
     },
     {
     DisplayName: manager.DisplayName,
     Claims: "i:0#.f|membership|" & manager.Mail
     }),
     Not(IsBlank(DisplayName))),
     Parent.Default)

    The Filter that wraps the Table function is needed in case you have a person with no manager (such as the CEO), and you don't want them to see a selection that is empty.

     

    Hope this helps, and kudos to Carlos for a great blog!

     

    RT

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard