Wednesday 12 October 2016

SharePoint 2013 (CSOM): Star Ratings Programmatically Adding Star-Rating or Re-Rating a List Item.

This Blog is about SharePoint's Star Rating Feature and how to change/read the Field Values Programmatically using CSOM. That is basically Rating or Re-rating the item.

What can be done by the following code is :
  • Select a list (should have ratings enabled).
  • Select the Item form the list.
  • Select a Site user whom you need to rate.
  • Finally the main code
    • To change the user's rating.
              OR
    • To rate the item.
  • To view the field values.

Most of the aspects of Star Rating are being covered but how Un-rate is intentionally not being covered as the user cant un-rate the item in SharePoint out of the box. If you want a code to un-rate the item please comment about it, I would Post it later.  
Note: Please use it for Ethically.
Code:
1. Console apps main Program code.
                 
2. Code of the FetchList Class.
                
3. Code of FetchItem class.
                
4. Code of SetUser class.
               
5.  Code to change the ratings packed in ChangeRating class.
                
Please feel free to comment on any related issues.



1 comment: