开发者

Sharepoint lookup field and WebId="

I try to add lookup field in content type. Field has this definition:

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

FavoriteSites list, which I want reference by this lookup field, exists on the site collection scope. Deployment goes fine, but when I create list based on content type with this lookup it looks like that lookup field is not connected to FavoriteSites list. I add some data into FavoriteSites and than I a try to add something into second list with lookup field on FavoriteSites. Unfortunately drop down select, which should show me data from FavoriteSites list is empty.

When I create ne开发者_JAVA技巧w lookup column to FavoriteSites manually everything is OK.

Do anybody have some idea where can be problem in this lookup definition?

UPDATE:

As Rich recommended me, I set log level on Verbose a find this message:

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}.

I don't understand it because list FavoriteSites exists. FavoriteSites list and also second list with Site field are deployed by one feature on site collection scope.

I can't specify list in lookup by GUID because I don't know the guid in deployment time.


What that log message means is that Lists/FavoriteSites does not exist in either the site collection root site or the site where the feature is being activated (if the latter is a subsite).

If Lists/FavoriteSites is being created by a feature, then make sure that it is activated before your Fields feature. Put the ListInstance element right above your Field element if you have to. But the message is clear: the list does not exist at the time that your custom field is being provisioned to the site collection. And that is why it is not working.

To be clear, the list has to exist at the time that the feature is activated, not just when you create a list instance that will use that field.

P.S. I found this by checking the "documentation" for the Microsoft.SharePoint.SPFieldElement.PerformFixUpIfLookUpField method.


Try changing the list field to the ID of the list e.g. List="{4641f5f2-b358-4805-9d7d-e910d2243fb5}"

I would also recommend using SharePointManager to look at the Field definition of your manually created field and to easily find the blooming guids of lists etc.


I had the same problem. In the end my problem was that you can not declaratively reference a list that is in the rootweb. The ~sitecollection token in the WebId property is not working because it will write the Guid between braces, while SharePoint expects it without braces (explanation can be found on http://martensboarterstun.wordpress.com/2013/06/15/how-to-create-a-list-definition-with-a-lookup-field-declaratively/). I ended up placing the Rootweb ID in my list definition.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜