Declaratively Create Look up Field Site Column in SharePoint Content Type

Ashok Raja
 
Solutions Architect
January 1, 2013
 
Rate this article
 
Views
245

Consider the below points to create a look up field as a site column and attach it to a content type in SharePoint 2010 or SharePoint 2013

1. Ensure that OverWrite attribute is set to true in Field Element

2. Ensure that List attribute is set to List ID or List URL

Find below the sample code for a content type and a site column referred in that content type.

 <?xml version="1.0" encoding="utf-8"?>
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
     <Field ID="{083AF243-688D-431A-8393-420FF838DF73}" Name="DemoColumn1" Group="Demo Group" DisplayName="Demo Column1" Type ="Text" />
     <Field ID="{0ACFBEC9-BC13-48F3-90B7-BA0600808118}" Name="DemoColumn2" DisplayName="Demo Column2" Group="Demo Group" Type ="Lookup" Mult="FALSE" Overwrite="TRUE" ShowField="Title" List="Lists/Category" />
     <!-- Parent ContentType: Item (0x01) -->
     <ContentType ID="0x0100e52212c906c741e19aa4bf85158533df"
                  Name="SFS.Tutorials.Basics - SFS Demo Content Type"
                  Group="Demo Content Types"
                  Description="Demo Content Type for Blog"
                  Inherits="TRUE"
                  Version="0">
         <FieldRefs>
             <FieldRef ID="{083AF243-688D-431A-8393-420FF838DF73}"  Name="DemoColumn1"    DisplayName="Demo Column 1"  />
             <FieldRef ID="{0ACFBEC9-BC13-48F3-90B7-BA0600808118}" Name="DemoColumn2"  DisplayName="Demo Column 2"  />
         </FieldRefs>
     </ContentType>
 </Elements>
Category : SharePoint

Author Info

Ashok Raja
 
Solutions Architect
 
Rate this article
 
I am Ashok Raja, Share Point Consultant and Architect based out of Chennai, India. ...read more
 

Leave a comment