let me just start by saying that I've searched for about 8 hours and I've read every accepted answer for CSOM, PowerShell, list settings etc and tried to convert the codes myself into a working JavaScript/jQuery solution with no luck.
I need to enable ratings to my Custom List within the App context when the app deploys. As of now the only way to get it to work is if I manually go to the URL of the list and create a new list item and rate it through the SharePoint UI.
The only way to make this work is to put a star between 1-5 on the newly created list item, liking doesn't trigger the needed feature.
to sum it up, when I deploy my app the list is created and I've added the needed fields to my list. When I create a list item through the App UI (through JavaScript) I've added the code to like/rate the item from the very start to trigger the rating feature but I receive:
"Content reputation feature is not activated."
I've tried to set this property through JSOM:
var context = new SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle("ratingsList");
var properties = list.get_rootFolder().get_properties();
context.load(list);
context.load(properties);
context.executeQueryAsync(function () {
properties.set_item("Ratings_VotingExperience", "Rating");
//properties.set_item("Ratings_x005f_VotingExperience", "Likes");
list.update();
context.load(list);
context.load(properties);
context.executeQueryAsync(function () {
// Success! the property is there and set to the correct value
}, DoError.JSOM);
}, DoError.JSOM);
Well, this "Works" the property is there when I fetch the properties but the feature isn't activated. The reason why I did this is because I started out by loading the properties to see what changes when the list item is rated with a star from the SharePoint UI and figured I could trigger this property through code.
So that doesn't work, the only thing that works is if I deploy the app and then create a list item through the SharePoint UI of the custom list and then rate it with a star between 1-5. After that, I can delete the list item and the code is running perfectly and all is good.
How is it that there is a 90% working solution for this? anyone had any luck/suggestions to this please post a line or two!
Remember that I ONLY need answers for SharePoint-Hosted Apps (Add-Ins) and not ProviderHosted.