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!
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
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?
Thank you I finally found something which worked.
Thank you!
I've tried a few solutions from this website and blogs and none of them was working but your!
Regards,
Slawek
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:
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:
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
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:
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:
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
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional