I have an SPListItem object from a list based on a custom content type. Many of the fields in that content type are lookup types that point to other lists. When I get back the SPListItem object for a list based on that content type, the value it contains for any lookup field is the ID from the lookup list, not the text that is displayed in the dropdown in the UI. If I try to create an SPFieldLookupValue to get the text, it just doesn't work because the intent of object seems to be the opposite, that you have the text and want to get the ID (MSDN Page). Here's the non-working function I have:
public static bool DocumentIsExpired(SPListItem item)
{
if (item.Properties["Expiry Status"] != null && !string.IsNullOrEmpty(item.Properties["Expiry Status"].ToString()))
{
var fieldVal = new SPFieldLookupValue(item.Properties["Expiry Status"].ToString());
if (string.Equals(fieldVal.LookupValue, "EXPIRED", StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (string.Equals(fieldVal.LookupValue, "UNEXPIRED", StringComparison.OrdinalIgnoreCase))
{
return false;
}
}
}
Do I just need to fetch the list and look it up myself? Or is there something wrong with how the content type was created or configured that I am seeing the ID and not the text in the SPListItem?