In this article I will discuss how to make use of ratings to your lists & libraries. Ratings are the features introduced by Microsoft which allow users to evaluate & rate the authors. Here I will explain how to use ratings on the lists & libraries.
So let’s get started.
In order to allow library visitors and contributors to rate library items, and to encourage interaction, ratings must be turned on for the library. Follow below steps to activate the Rating feature to manage list and library in SharePoint Online:-
Step 1
Create a “Document Library” inside your Team Site.
Note
For creating a Document Library refer my previous article where I have mentioned “Sample Document Management System”.
Refer to the below screenshot,
Step 2
Click on “Library” tab & select “Library Settings” option present on the top below screen will appear. Refer to the below screenshot,
Step 3
Go to “General Settings” & select “Rating Settings”. Refer to the below screenshot,
Step 4
Select the “Rating Settings” option to “Yes” and choose rating experience as “Star Rating” or “Likes” and click Ok. Refer to the below screenshot,
Step 5
Three new columns will be created as Rating (0-5), Number of Ratings and Number of Likes. Refer below screenshot,
Step 6
We have to check these three columns. For this go to your respective Document library and click on “Library” tab & select “Modify View”. Refer to the below screenshot,
Step 7
Check the “Ratings (0-5)” Checkbox and the column will appear in the document library. Refer to the below screenshot,
Step 8
To rate the documents upload a document & simply hover your mouse on the “Rating (0-5)”column. Refer to the below screenshot,
OR,
This can be achieved by using Server Side Coding. Follow below steps,
Step 1
Add dll as “Microsoft.SharePoint.Portal.dll”.
Step 2
Make changes to “Enable Rating” & “Disable Rating” Methods. Refer to the below screenshot,
-
- publicstatic void enableRating(SPList oList)
- {
- Type type = typeof(Microsoft.SharePoint.Portal.RatingsSettingsPage);
- MethodInfo mi = type.GetMethod("EnableRatings", Static | BindingFlags.NonPublic);
- Invoke(null, newobject[]
- {
- oList,
- false
- });
- }
-
- publicstaticvoid disableRating(SPList oList)
- {
- Type type = typeof(Microsoft.SharePoint.Portal.RatingsSettingsPage);
- MethodInfo mi = type.GetMethod("DisableRatings", Static | BindingFlags.NonPublic);
- Invoke(null, newobject[]
- {
- oList
- });
- }
OR,
We can use PowerShell script to use ratings in our lists & libraries. Refer to the below screenshot,
- Add - PSSnapin "Microsoft.SharePoint.PowerShell" - ErrorAction SilentlyContinue
- $web = Get - SPWeb "http://abc.com/test";
- $list = $web.Lists["Pages"];
- if ($list - ne $null)
- {
- Write - Host $list.Title "not null";
- $assembly = [System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
- $reputationHelper = $assembly.GetType("Microsoft.SharePoint.Portal.ReputationHelper");
- $bindings = @("EnableReputation", "NonPublic", "Static");
- [System.Reflection.BindingFlags] $flags = [System.Reflection.BindingFlags]::Static - bor[System.Reflection.BindingFlags]::NonPublic;
- $methodInfo = $reputationHelper.GetMethod("EnableReputation", $flags);
- #For enabling Ratings
- $values = @($list, "Ratings", $false);
- #OR
- for enabling Likes# $values = @($list, "Likes", $false);
- $methodInfo.Invoke($null, @($values));
- #For disable Rating or Likes <
- #
- $methodInfo = $reputationHelper.GetMethod("DisableReputation", $flags);
- $disableValues = @($list);
- $methodInfo.Invoke($null, @($disableValues));
- # >
- }
So these are the processes through which we can achieve ratings in respective Lists or Libraries.