we were tasked to create a system in which users have the ability to rate a content using the star rating. i understand that sharepoint has an ootb functionality for the star rating however it just shows the average rating for that particular item. we can use that one to display the average rating but what i need to find out is how to display the rating of the currently logged in user of that paritcular content.

we were thinking of having another list for it which contains that user, the id of the content (from doc library) and the rating. but this doesn't seem feasible because there would be thousands of users and managing the list like that may not be a good practice.

what would be a good approach to store a user rating for a particular doc lib item?

  • If scale is a concern the only real answer is an external database with a web service front end. – Derek Gusoff Dec 5 at 16:46

The RatedBy and Ratings property contains the rated user and rating values, so you could iterate the array and find the mapping rating value.

Sample code of JSOM, and I think you could get the properties by pnp library in SPFx solution.

function CustomJS() {
            var ctx = SP.ClientContext.get_current();
            var web = ctx.get_web();
            var list = web.get_lists().getByTitle("Doc4R");
            var item = list.getItemById(3);
            ctx.load(item);
            ctx.executeQueryAsync(function (sender, args) {
                var _RatedBy = item.get_item('RatedBy');
                var _Ratings=item.get_item('Ratings')
            })        
        }
  • oh so we shoudl be able to get the rating of a user as well? we'll check on this thank you! – Page F.P.T Dec 6 at 1:48

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.