Overview
One of the very useful column is People metadata. Usage of this metadata is strongly advised when your column is meant for people that is part of your Active Directory. One sample metadata that is type of people is the Created By and Modified By with the internal name of “Author”. Those 2 are by default available when you create a List or even a document library, an events, calendar, announcements, and many more. People metadata is not like the other types of metadata like Single line of text or number or Multiline, this metadata is an object by design which offer more properties than what we can see. It is hidden by default but we can always get some of its properties by expanding it.
Expand with Rest API
You can expand People metadata properties by accessing its rest api url with
/_api/web/Lists/GetByTitle('listname')/Items?$select=*,CreatedBy/Title, CratedBy/EMail&$expand=CreatedBy
A sample returned object would look like this
Author: {
EMail: "John.Doe@mycompany.com"
Title: "John Doe"
}
You can also access the properties you can see in the User Information page. Access it via the URL below
/_layouts/15/userdisp.aspx?Force=true
Property Internal Names
Internal Name | Display Name |
ID | ID |
Title | Name |
Name | Account |
FirstName | First Name |
LastName | Last Name |
Department | Department |
JobTitle | Title |
Work-email | |
WorkPhone | Work Phone |
MobilePhone | Mobile Phone |
SipAddress | SIP Address |
UserName | User Name |
Office | Office |
Modified | Modified |
Created | Created |
Explore also objects that are already present like user properties in SharePoint pageContext
Expanding People metadata with PnP
Custom development with SharePoint is really made easy with the help of PnP. Below is how we expand people metadata with it. Its just a simple function that returns list item’s Author name and email.
const _getItem = async (props: {listId: string}) =>{
return await sp.web.lists.getById(props.listId).items
.select("Author/Title,Author/EMail")
.expand("Author")
.getAll();
};
Now that’s another tip! Hope it helps somehow. Let me know if you have questions or just leave a comment if we missed something.
Happy SharePointing! #SharingIsCaring
Accounting.js Cascading StyleSheet Cheat Sheet Collaboration Competitors Connect Content Type CSS Currency Design Flows HTML5 Issues Javascript JavsScript Microsoft Teams NodeJs Numeral.js O365 Office 365 OneDrive Overflow PnP Power Automate PowerAutomate PowerShell Pwermissions ReactJs Rest Endpoint Send an HTTP Request to SharePoint SharePoint SharePoint Architecture SharePoint Designs SharePoint Modern SharePoint Online ShellScript SPFX SPO Styling Sync Tags Taxonomy Teams Teams App Transform JS