Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 !

share|improve this question
add comment

1 Answer

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

FieldLookup myLookupField;
//Configuration of Field Stuff
lst.Fields.Add(myLookupField);
share|improve this answer
    
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
add comment

Your Answer

 
discard

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.