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've got a big problem with creating Lookup field between two lists which are deployed on site collection scope. I've got this field definition:

 <Field ID="{c80e8e3c-7124-4772-a39d-5b69f131d542}"
             Name="Site"
             Group="Intranet Columns"
             Type="Lookup"
             DisplayName="Site"
             StaticName="Site"
             Overwrite="TRUE"
             WebId="~sitecollection"
             List="Lists/FavoriteSites"
             ShowField="Title"
       />

This field referenced by content type:

   <FieldRef ID="{c80e8e3c-7124-4772-a39d-5b69f131d542}" Name="Site" DisplayName="Site" Required="TRUE"/>

This content type is referenced in list definition by ContentTypeRef. Both lists are deployed by feature on Site collection scope - definition and also instances. Everything goes fine. But when I add something into FavoriteSites list and than when I try add something into second (connected) list there is nothing in drop down list for lookup field. It looks like that lookup field is not connected to FavoriteSites list.

Have anyone some idea?

share|improve this question
    
Hi Michal, do let me know if I have misinterpret your question - what you mean is that you have two list in your SharePoint 2007, one is 'FavoriteSites' and another List B (that you connect to the 'FavoriteSites' list). So, when you add a item in the 'FavoriteSites' list, you should be able to get that item inside one of your drop-down field column in List B but right now, the drop-down field in List B shows nothing. –  Wilson Tan Sep 14 '11 at 9:11
    
Hi Wilson. You understood my question completely! Just I'm using Sharepoint 2010. I have list FavoriteSites and connected list B. Both lists are deployed on site collection scope by the same feature. –  Michal Sep 14 '11 at 18:32
    
I set Sharepoint log severenity to Verbose and I founded this message in log: The WebId=~sitecollection and List=Lists/FavoriteSites attributes specified for field {c80e8e3c-7124-4772-a39d-5b69f131d542} in feature {d86c7005-d31d-43ae-b86b-38f28b81072e} could not be found. Set List={39CEC23E-FB28-47B3-BC36-C21780AD1D94}. But list on URL Lists/FavoriteSites exist after deploy, so i don't understand it. –  Michal Sep 14 '11 at 18:34
add comment

1 Answer

up vote 0 down vote accepted

Creating Lookup fields with CAML has always been a bit fiddly, there are a few things I would suggest trying.

  1. I'd remove the WebId="~sitecollection". I've not seen this syntax before, and I don't think it's valid. If you're activating the feature on the root of the site collection SharePoint will assume you're using the root web anyway.

  2. Ensure your list is being created before the feature containing the Field is activated. There are some rules around using the Url of the list in CAML, but I can't seem to find them....

If it still doesn't work, I would fall back on the tried, and true method of configuring the Lookup fields via code in a Feature receiver. See this question for a few of your options.

share|improve this answer
    
Thanks Neil. My problem was caused by bad order of feature ativating. –  Michal Sep 15 '11 at 6:12
add comment

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.