0

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 my 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

0

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.