SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get a FieldLookup from a list (already queried). First line in the below code errors out "Unable to cast Field to FieldLookup". Yes, the field I am trying to retrieve is a lookup field only. Any help?
list - A sharepoint list
ctx - ClientContext instance

var fieldLookup = (FieldLookup)list.Fields.GetByInternalNameOrTitle("ALookupField");  
ctx.Load(fieldLookup, (s) => s.LookupList);  
share|improve this question

Found a hack to get the lookup list id.

    var field = list.Fields.GetByInternalNameOrTitle("ALookupField");  
    ctx.Load(field, (s) => s.SchemaXml);  
    var lookupListId = XElement.Parse(field.SchemaXml).Attributes().First(s => s.Name == "List").Value;  

Logically one would think that this List prop in schema corresponds to the list the field belongs to, but the fact is, it corresponds to the LookupList. That's MS way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.