PowerApps-无法将SharePoint Person / People字段设置为Current User

时间:2019-03-27 19:01:34

标签: office365 sharepoint-online powerapps peoplepicker

我可以在PowerApp中为当前用户设置一个人员字段。我已按照以下教程进行操作,但下拉控件未设置为当前用户。这种方法似乎是如何做到这一点的普遍共识。我一定错过了一步。

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

我的屏幕的OnVisible属性:

BarInline

人员字段下拉控件的默认属性:

//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})

更新人员字段DataCard的属性:

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

结果-应该使用当前用户填充

blank person field

1 个答案:

答案 0 :(得分:0)

我在下面的帖子中找到了答案。根本问题是需要在下拉控件上设置的属性。它应该是 DefaultSelectedItems。。此外,传递给控件的记录仅需要DisplayNameClaims属性。

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

屏幕上的可见事件

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

DefaultSelectedItems

If(varAlwaysTrueForTest, myself, Parent.Default)