Lookup Field as a Site Column via CAML

sharepoint

I'm trying to create a Lookup Field as a Site Column via CAML. The list I want to use as the source of the lookup is created in the Feature Receiver so I don't know it's ID. I've read several blog posts that indicate that I can just put the path to the list in the List attribute. It seems from the comments on these post that this solution works for some people but not for others. I'm in the latter group.

When I try to associate a content type that uses the lookup site column I: "Exception from HRESULT: 0x80040E07"

<Field 
  ID="{da94e56b-428f-4b95-b4c6-24aed0256475}" 
  Name="Test_x0020_Lookup_x0020_Column"
  StaticName="Test_x0020_Lookup_x0020_Column" 
  DisplayName="Test Lookup Column" 
  Type="Lookup" 
  Required="FALSE" 
  List="Lists/Test" 
  ShowField="Title" 
  PrependId="TRUE"
  Group="Test Site Columns" />

  <ContentType
    ID="0x0100B6D92594DDCE8E479D0EB0C414C463B0"
    Name="Test Lookup Content Type"
    Version="0"
    Group="Test Content Types">
    <FieldRefs>
      <FieldRef 
         ID="{da94e56b-428f-4b95-b4c6-24aed0256475}" 
         Name="Test_x0020_Lookup_x0020_Column" 
         Required="TRUE" />
    </FieldRefs>
  </ContentType>

Best Answer

Be sure to add this property when creating the site coloumn Overwrite="TRUE"

Related Topic