Data,  Functionality

Person Fields – reading and writing options

There is often a challenge exploring the various options of searching and saving details into SharePoint Person fields, both single and multiple choice. This blog explores the various ways that Users can be chosen and saved.

Standard choices

There is often confusion around the “standard” provided Items which do not always provide a full list of employees.

Choices(ListName.FieldName)

These Items only provide a choice of people already in the SharePoint List – if everyone is already in there, then this can be used, otherwise one of the other two options below is needed. Also, the syntax the Schema (Table structure) of a Person Field matches that of the Items Table, so no modification of the DefaultSelectedItems (Parent.Default or ThisItem.ThePersonFieldName) or Data Card Update (ComboBoxName.Selected or ComboBoxNameSelectedItems for multiple choices) is required.

Office365Users

The Office365Users.SearchUser Function gives access to the full Entra list for the organisation. There is some flexibility of what is retreived – this Items example

Office365Users.SearchUserV2(
   {
      searchTerm: Self.SearchText,
      isSearchTermRequired: false,
      accountEnabled: true,
      top: 999
   }
).value

allows the list to be displayed without search input (useful for small numbers), displays only current users and up to 999 entries. You can also filter this (example by Department)

Filter(
   Office365Users.SearchUserV2(
      {
         searchTerm: Self.SearchText,
         isSearchTermRequired: false,
         accountEnabled: true,
         top: 999
      }
   ).value,
   Department = "Finance"
)

When this Schema is used, there is some modification required to the DefaultSelectedItems of the Combo Box and the Update of the Data Card to match that of the Person field. DefaultSelectedItems (single choice)

{
   DisplayName: ThisItem.PersonFieldName.DisplayName,
   Mail: ThisItem.PersonFieldName.Email
}

DefaultSelectedItems (multiple choice)

ForAll(
   ThisItem.PersonFieldName As _Data,
   {
      DisplayName: _Data.DisplayName,
      Mail: _Data.Email
   }
)

Data Card Update (single choice)

{
   Claims: "i:0#.f|membership|" & Lower(ComboBoxName.Selected.Mail),
   Department: "",
   DisplayName: ComboBoxName.Selected.DisplayName,
   Email: ComboBoxName.Selected.Mail,
   JobTitle: "",
   Picture: ""
}

Data Card Update (multiple choice)

ForAll(
   ComboBoxName.SelectedItems As _Data,
   {
      Claims: "i:0#.f|membership|" & Lower(_Data.Mail),
      Department: "",
      DisplayName: _Data.DisplayName,
      Email: _Data.Mail,
      JobTitle: "",
      Picture: ""
   }
)

Group membership

A filter on the membership of an Office365 Group can also be used for the Items of the Combo Box. For this you will need the Group ID, which can be obtained in the Office365 Admin Centre in the URL of the Group when selected.
The Items of the Combo Box would follow this example

Office365Groups.ListGroupMembers(
    "YourGroupIDHere"
).value

This Schema also differs from that of a Person field and requires modification of the same elements as above. 
DefaultSelectedItems (single choice)

{
   displayName: ThisItem.PersonFieldName.DisplayName,
   mail: ThisItem.PersonFieldName.Email
}

DefaultSelectedItems (multiple choice)

ForAll(
   ThisItem.PersonFieldName As _Data,
   {
      displayName: _Data.DisplayName,
      mail: _Data.Email
   }
)

Data Card Update (single choice)

{
   Claims: "i:0#.f|membership|" & Lower(ComboBoxName.Selected.mail),
   Department: "",
   DisplayName: ComboBoxName.Selected.displayName,
   Email: ComboBoxName.Selected.mail,
   JobTitle: "",
   Picture: ""
}

Data Card Update (multiple choice)

ForAll(
   ComboBoxName.SelectedItems As _Data,
   {
      Claims: "i:0#.f|membership|" & Lower(_Data.mail),
      Department: "",
      DisplayName: _Data.displayName,
      Email: _Data.mail,
      JobTitle: "",
      Picture: ""
   }
)

To summarise, the Schema differences are

  • Office365Users has Mail instead of the Person field Email
  • Groups has displayName and mail instead of the Person field DisplayName and Email

I have also used the As disambiguation operator for the multiple choice examples – although not strictly necessary, it is more specific and always works.

I hope this is useful for your navigation of this field type and its population.

5 Comments

  • Walt

    Nice, for Office365Users I had to change some fields to the below and it worked wonderfully when submitting to my SP List. You will notice the user of Concatenate and no colon

    {
    Claims: Concatenate(
    “i:0#.f|membership|”,
    _Items.Mail
    ),
    Department: “”,
    DisplayName: _Items.DisplayName,
    Email: _Items.Mail,
    JobTitle: “”,
    Picture: “”
    }

  • Darienne Kreeger

    I’ve been working on an issue with my person fields for daaaaaaays and this solved it! Bless you!!!

Leave a Reply

Your email address will not be published. Required fields are marked *