Trying (desperately) to find the Microsoft.Sharepoint.Client equivalent of SPList.Fields.Addlookup

My code:

ClientContext ctx = new ClientContext("http://sharepoint/");
Web website = ctx.Web;
ListCreationInformation ci = new ListCreationInformation();
ci.Title = "MyList";
ci.TemplateType = (int)ListTemplateType.GenericList; 
List lst = website.Lists.Add(ci);
lst.AddLookup // <- THIS DOES NOT EXIST
lst.Fields.AddLookup // <- NOR DOES THIS 

I've tried using AddFieldAsXml with every conceivable combination of attributes/values - no luck

Any help would be greatly appreciated !


You can create a new instance of the FieldLookup object and then use

FieldLookup myLookupField;
//Configuration of Field Stuff
  • Tried that, unfortunately you can't new up a LookupField without knowing the 'object path' - the signature is FieldLookup fld = new FieldLookup([ClientRuntimeContext Context], [ObjectPath ObjectPath]); There's no documentation on the constructor - it seems that MS has reservered it for internal use - (mind you, if there IS another way to create the Lookfield , please let me know)
    – Marc
    Apr 25 '12 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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