I am trying to update/create property in PropertyBag. Its working fine on classic experience (developer site and document center) but its not allowing application to start on modern site collections(root site, communication site and team site) and its not setting property in PropertyBag.
When I try to run application root site collection after installation its throwing this error
Access denied. You do not have permission to perform this action or access this resource.
Please tell me how can I set property in property bag for root site, communication site and team site.
Code:
var context = SP.ClientContext.get_current();
var web = LawApp.Repositories.getWeb(context, hostUrl);
var props = web.get_allProperties();
props.set_item("CurrentVersion", 2002);
web.update();
context.executeQueryAsync(success, fail);
I solved it by change the value of "CurrentVersion" to string because property bag does not take integer values. You can check this link too. https://sharepoint.stackexchange.com/questions/171244/setting-propertybag-values-in-sharepoint-online/171247