• AndyH

Get the SPUser details

Updated: Mar 13, 2019


When querying a list or library that contains a 'Person or Group' column, the data returned only includes the user Id by default. So how do you get the other user properties such as their name and email address?


The answer is in select and expand from the REST API. Consider the following example, where a column called Approver exists on a list and is a 'Person or Group' type:

return sp.web.lists.getByTitle( _listName ) .items .select( "Id, Title, Approver/Title, Approver/EMail" ) .filter( `Title eq ${ title }` ) .expand( "Approver/Id" ) .get();

The select parameter references the properties Title and EMail (note case is important) on the Approver column. This on its own will not return the associated data.


The expand parameter references the Approver/Id and this completes the puzzle. The Approver Title and EMail can now be returned.


Other fields can include SipAddress, Name, FirstName, LastName, JobTitle and Department amongst a handful of others. I have yet to test all of these but there were a couple of issues I found:

  1. The property names are case sensitive, so it must be SipAddress and not SIPAddress.

  2. I have not found a Picture property for the user, but I have a separate post about how to get the users picture.

0 views

 

© 2019 AndyH  -  all rights reserved