Extending & troubleshooting SharePoint 2010 rating related features

fix

Tuesday, January 19th, 2010

Last few weeks I have been crazy busy extending SharePoint 2010 rating control. As you know default SharePoiunt 2010 rating control is 5-star scale.

One of the tasks I had to do is to perform my own calculations based on each time the AverageRating has been updated. As you may know average rating gets calculated on a Job schedule defined in Central Administration. You can set that job to run every minute if you like. Once the job runs – it will take the infromation from rating database and place it to the content database thus showing average. The problem I faced is that my even handler – perfectly tied to a list and executing all of the updates I do on the list – wouldn’t trigget on rating updates.

Here is how to fix this issue:

By enabling rating in Lists Settings of your list – all that SharePoint does is creates 2 fields. You will need to set pushchangestolist property of 2 created fields (Rating (0-5)  and Rating Count) to true. The way I approached it – is simply by creating a feature that enables twose 2 fields and sets all of the appropriate values. Here is an article where you can get the code on how to do that.

Now your rating field changes will trigger events on the receiver. You probably want to know how to debug your code since attaching to W3P won’t work. Keep in mind that all of the events that are running on the schedule are running with OWSTIMER process, which is Windows SharePoint Services Timer. You want to attach your Visual Studio 2010 debugger to that. It won’t capture your other events such as page updates etc, but will capture job execution.

Good luck!

news

Any information posted on this blog does not reflect views of respective product vendors unless explicitely stated.

featured