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 features that define site content types and a document library template that uses these content types. Now, when I create a document library from the template, all the content types appear there as expected with the metadata, except for lookupfields. They have to be added manually to the library's content types after creating the library from template.

As I searched the code, there was an intended fix for this while deploying the lookupfields:

SPList MyList = currentWeb.Lists["MyListName"];


This would work well if I had already created the document library from the template, which I haven't.

Are there any solutions for this? I'd guess:

  1. also create the document library with a feature from the template and use the existing code (which wastes the point of using a document library template at all)
  2. somehow manipulate the document library template to include the lookup fields
share|improve this question
Are you trying to deploy the lookup list along with the current library template? – sssreddy Jan 15 '13 at 15:09

If you would like to update the content type when a new list is added you can implement the above code in a ListAdded event receiver. You can check if the list added is of your library template and update the content type.

Not sure if you have a specific reason to do it via object model. You can deploy the lookup field configured properly in your library template. If you are deloying the lookup list along with the your library template, you just have to split them into different feature and ensure they are activated in proper order.

share|improve this answer

Check out this old post from Josh Gaffey about adding declarative lookup columns you may also like to pre-populate your lookup list

share|improve this answer
This doesn't seem to help with the document library TEMPLATE issue... – Indrek Feb 1 '12 at 11:53

You can create site column with type lookup and use that in your created library. In this example they referred global data between two lists by creating site columns..Refer this

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.