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

I was wondering if it's possible to create a content type using C# that has two columns, the second column looks up the first column.

eg.

Title | myColumn

myColumn should be a lookup column and it looks up 'Title' from the same content-type I want construct.

Using the AddLookUp() constructor expects a [Name], [ListId/Guid], [Required]. Unfortunately there is no list to reference reference the lookup as the lookup column is in the same content type that I want to create.

I did a bit of digging on the web and Google but haven't found anything using C# but found something similar in the blogs below talking about self referencing list.

http://hristopavlov.wordpress.com/2008/05/15/lookup-fields-to-the-same-list-defined-as-a-site-column/

http://www.novolocus.com/2008/04/25/self-referencing-lookup-columns/

My question is, is this 'doable' using SharePoint's server object model?

share|improve this question

1 Answer 1

You can't create a lookup to a content type, only to a list - which makes sense because content types don't hold data, they merely define what data looks like.

So what you need to do is create the list, then add the lookup column back to the list content type.

share|improve this answer

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.