Home » General Scripting and Coding » SharePoint » Parsing a SharePoint Lookup Field using SPFieldLookupValue

Parsing a SharePoint Lookup Field using SPFieldLookupValue

Posted on by

This is a quick example of parsing a SharePoint Lookup field using SPFieldLookupValue.  As we know, SharePoint lookup fields are usually formed as such:

[Lookup ID];#[Lookup Value]

Rather than manually parsing this result (by perhaps splitting the returned string by ‘;#’) we can simply obtain these values using the SPFieldLookupValue:

SPFieldLookupValue splv = new SPFieldLookupValue(oListItem["User_x0020_Email"].ToString());

lookupIdStr = splv.LookupId.ToString();
lookupValueStr = splv.LookupValue.ToString();

 

 

Comments have now been disabled. If you have a question to ask about this post please ask the community!