fbpx

February 26, 2011

Enable rating in SharePoint 2010 custom content types

Enable rating in SharePoint 2010 custom content types

To turn on ratings on a list you normally go to Library/List Settings > Rating Settings. 

 

 When you enable this on a list or a library SharePoint adds two columns to your list called:

  • Rating (0-5)
  • Number of Ratings

But if you want to provision the rating with your Content Types and solution packages – you have to add the two rating columns to your content type.

 Solution is here

Create an empty SharePoint project in Visual Studio 2010 and add a new Content Type project item. Select a content type to derive your new content type from. Once the item is added then you will see the content type XML manifest. Add the following rating site columns as a FeildRef.

<FieldRefs>
  <FieldRef ID="{5a14d1ab-1513-48c7-97b3-657a5ba6c742}" Name="AverageRating" />
  <FieldRef ID="{b1996002-9167-45e5-a4df-b2c41c6723c7}" Name="RatingCount" />
</FieldRefs>

Add a new item to the project of the type “List Definition from Content Type” and use your newly created content type. Also check the checkbox to create a list instance. Then deploy your solution to SharePoint and navigate to the new list that should have been created. If you create a new list item or upload a document you will see that the Rating has been enabled.

You can also check the Rating Settings for the list or the library and verify that Ratings has been enabled.

  • Related Tags:

(5) Comments

  1. Nike MS78

    I learn something new on different blogs everyday. It is always refreshing to read blogs of other bloggers and learn something from them. Thanks for sharing!!
    curt

  2. Santi

    Thank you very much, works fine. I tried to create the fields, and was not working properly, and only had to refer to them.

  3. Путаны Москвы

    The rating allows users to rate items in lists and libraries in SharePoint. This is another highly usable and awesome feature tied to the Managed Metadata Service Application (MMS).
    To turn on ratings on a list you normally go to Library/List Settings > Rating Settings.

Leave a comment