How to enable target audiences for custom content types. In custom list definition.

by James 3/9/2008 8:59:00 PM

We often take following steps to create custom list and add it to the site

a. Create custom content types with custom site columns.

b. Create custom list definition and references custom content types.

c. Create list instance as feature and activate it on the site we want to have this custom list.

To enable audience targeting for custom content type during list instance creation. We have to add one more field reference to content type.

step 1.

<ContentType ID="ENTER_GUID_HERE"
             BaseType="ENTER_BASE_TYPE_GUID_HERE"
              Group="CONTENT_TYPE_GROUP"
             Name="Custom Content Type"
             Description="My custom content type">
            <FieldRefs>
                <!-- other custom site columns omitted -->
                <FieldRef ID="{61cbb965-1e04-4273-b658-eedaa662f48d}" Name="Target_x0020_Audiences"/>
            </FieldRefs>
</ContentType>

Above adds target audiences setting field to content type.

James Tsai .NET C# SharePoint VSTO Target Audiences Content Type

Step 2. we also have to add the following field to list definition.

<!-- List schema.xml -->
<Fields>
<!--other field refs omitted -->
<Field ID="{61cbb965-1e04-4273-b658-eedaa662f48d}"
         Type="TargetTo"
          Name="Target_x0020_Audiences"
          DisplayName="Target Audiences"
          Required="FALSE"
          StaticName="Target_x0020_Audiences"
          SourceID="http://schemas.microsoft.com/sharepoint/v3"
      />
</Fields>

After you added custom list on the site, you can see that target audiences has been enabled for content type.

James Tsai .NET C# SharePoint VSTO Target Audiences Content Type

Note: If you enable target audiences from the UI and you have more than one content types for a list. Target audiences field will be enabled only for the first content type.

You have to add target audiences field reference (step 1) to all your content types in list. For them to support target audiences.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

SharePoint

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen Adopted by James Tsai

About the author

Name of author James Tsai
.NET and SharePoint consultant

E-mail me Send mail

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678
View posts in large calendar

Certifications

MCPD
MCTS

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009

Sign in