Kae Travis

Parsing a SharePoint Lookup Field using SPFieldLookupValue

Posted on by in SharePoint

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();

 

 

Parsing a SharePoint Lookup Field using SPFieldLookupValue
Parsing a SharePoint Lookup Field using SPFieldLookupValue

Leave a Reply