How to look up the document library in its local sub site where used, rather than in the root site?

StackOverflow https://stackoverflow.com/questions/7268097

Question

I have a content type that has a lookup field for a document library in its sub site. The content type is declared a site collection root level but I want the look up field to look up the document library in its local sub site where used. I deploy the content types using PowerShell and have used an event receiver to add the look up field. I can't however get it to reference the correct list, it only ever references the list at the root site collection.

How can I overwrite the look up list?

Was it helpful?

Solution

I avoid setting the List attribute in the Field element. I have had problems saving the site as a template when a custom Field has the List attribute set. But the other problem is that these properties are write-once. Better to leave it blank in the definition and then set it in the instance programmatically using SPFieldLookup.LookupWebId and SPFieldLookup.LookupList.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top