web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Auto populate person t...
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!

Categories:
I have the same question (0)
  • RusselThomas Profile Picture
    4,014 on at

    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

  • Verified answer
    v-xida-msft Profile Picture
    on at

    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

  • TheSlawekG Profile Picture
    119 on at

    Thank you!

     

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

     

    Regards,

     

    Slawek

  • hyperbob0811 Profile Picture
    91 on at

    Thank you I finally found something which worked.

  • gstlouis Profile Picture
    on at

    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?

  • gstlouis Profile Picture
    on at

    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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard