4

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 !

1 Answer 1

3

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

FieldLookup myLookupField;
//Configuration of Field Stuff
lst.Fields.Add(myLookupField);
1
  • 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) Commented Apr 25, 2012 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.