Posts

Showing posts from August, 2015

Get the mail address from a FieldUserValue Client Side vs Server Side

In SharePoint are two ways to code by using an object model. The one way is the Client-Side Object Modell (CSOM) and the other side is the Server-Side Object Model (SSOM). At the first look they both look the same the only difference is how the objects are looking for example the is the 'Site'-object (client side) is called 'SPSite' on server side. A good way to demonstrate the difference is to get the mailaddress of a userfield. That sounds easy, but needs more lines that I thought at first. So let's say you got a SharePoint 2013 and want to read the mailaddress on client side. That would look like this: 1 2 3 4 5 6 7 8 9 // get the userfield of the item e.q. Author FieldUserValue Author = (FieldUserValue)currentItem[ "Author" ]; // ask the web to find a user with the id in the field (only works if the user visited the site) var user = web.SiteUsers.GetById(Author.LookupId); // load the data with the context context.Load(user); context.ExecuteQue