In my Editform I wish to reset all the ratingcounts on save, however I am getting an error message
Save Conflict. Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.
There is no other user. There is another update in the save action, which does a get / update on the ratings variable.
There is no overlap between the columns being updated on the editform and through the rating update code, so how can I force the code to accept both updates? The AllowUnsafeUpdates parameter does not seem to make any difference.
I am doing it this way as I don't know any other way of updating the ratings on the editform.
function MyPreSaveAction (){
// Update other fields on the item
var fieldvalue = 'Purple';
$("input[Title='Other field']").val(fieldvalue);
var context = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var list = context.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var getweb = context.get_web();
getweb.AllowUnsafeUpdates = true;
var itemID = parseInt(GetUrlKeyValue('ID'));
var item = list.getItemById(itemID);
context.load(item, "RatingCount", "RatedBy","AverageRating");
item.set_item('AverageRating',5);
item.set_item('RatingCount',0);
item.set_item('RatedBy',[]);
item.update();
context.executeQueryAsync(RetrievedListID, ExecutionFailed);
//response handler
function RetrievedListID(sender, args) {
}
//error handler - generic
function ExecutionFailed(sender, args) {
}
getweb.AllowUnsafeUpdates = false;
var areOtherValid = typeof(__OriginalPreSaveAction) === "function" ? __OriginalPreSaveAction():true;
return amIValid && areOtherValid;
}
function RegisterMyPreSaveAction(){
PreSaveAction = MyPreSaveAction;
}