Forum Discussion

Asjad_Ali's avatar
Asjad_Ali
Copper Contributor
Oct 05, 2020

How to set property in property bag on root site collection using JSOM?

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.

 

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);

 

Resources