I wish to reset the ratings for an item after a list item is edited. I can get the Average rating to be reset back to 0, but not the ratingCount. How can I do this?
The code I am using is
var context = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var list = context.get_web().get_lists().getById(_spPageContextInfo.pageListId);
// test case is item 2 in my list
var item = list.getItemById(2);
context.load(item, "RatingCount", "AverageRating");
context.executeQueryAsync(RetrievedListID, ExecutionFailed);
function RetrievedListID(sender, args) {
var rc = item.get_item("RatingCount");
var ar = item.get_item("AverageRating");
item.set_item('AverageRating',0);
item.set_item('RatingCount',0);
item.update();
context.executeQueryAsync(RetrievedListID1, ExecutionFailed1);
function RetrievedListID1(sender, args) {alert('Done')};
function ExecutionFailed1(sender, args) {alert('Failed')};
}
function ExecutionFailed(sender, args) {
alert('Failed');
}
}