0
votes

I am uable to set a person field to the current user in a PowerApp. I have followed the tutorial below but the dropdown control is not set to current user. This approach seems to be the general consensus on how to do this. I must be missing a step.

http://www.codeovereasy.com/2017/07/powerapps-set-sharepoint-person-field-to-current-user/

OnVisible property of my screen:

//Here I am setting the person field record to a variable 'myself' with current user values
Collect(Collection1, {Pressed: Button1.Pressed});
 UpdateContext({ 
  myself: { 
   '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims:"i:0#.f|membership|" & Lower(User().Email),   
    Department:"", 
    DisplayName:User().FullName,
    Email:User().Email, 
    JobTitle:".", 
    Picture:"."
  },
  manager: Office365Users.ManagerV2(Office365Users.MyProfile().Id).mail,
  varAlwaysTrueForTest: true})

Default property of person field dropdown control:

//This should show the current user in the dropdown control after the screen becomes visible
If(varAlwaysTrueForTest, myself, Parent.Default)

Update property of person field DataCard:

//DataCardValue6 is my person dropdown control
If(varAlwaysTrueForTest, myself, DataCardValue6.Selected)

Result - should be populated with current user

blank person field

1
Please leave a comment if you have an issue with my post. I cannot improve it if you down vote without context.ExceptionLimeCat

1 Answers

0
votes

I discovered the answer in the post below. The root issue is the property that needs to be set on the dropdown control. It should be the DefaultSelectedItems. Also, the record being passed to the control only requires the DisplayName and Claims properties.

https://powerusers.microsoft.com/t5/General-Discussion/How-to-set-a-defaul-value-for-a-person-fields-in-a-SharePoint/m-p/188290#M61575

OnVisible event of screen

UpdateContext({ myself: 
 { 
    Claims:"i:0#.f|membership|" & Lower(User().Email), 
    DisplayName:User().FullName 
 }
})

DefaultSelectedItems

If(varAlwaysTrueForTest, myself, Parent.Default)