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 have an existing list "Country List", Column "COUNTRY" contains name of the all the countries.

I would like to create a look up field "Origin Country" in a list "Order List" via OM. How do I do that?

share|improve this question
Through the UI or through code? – Colin Jun 9 '11 at 21:05
OM would suggest object model - I'll update the title to make that clear. – Andy Burns Jun 10 '11 at 8:48
up vote 3 down vote accepted
var list = web.Lists["Order List"];
var targetList = web.Lists["Country List"];
var fieldName = list.AddLookup("Origin Country", targetList.ID, true);
var field = list.Fields.GetByInternalName(fieldName) as SPFieldLookup;
field.LookupField = targetList.Fields["COUNTRY"].InternalName;
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.