如何使用 JSOM 在根网站集的属性包中设置属性? [英] How to set property in property bag on root site collection using JSOM?

查看:59
本文介绍了如何使用 JSOM 在根网站集的属性包中设置属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更新/创建 PropertyBag 中的属性.它在经典体验(开发者网站和文档中心)上运行良好,但不允许应用程序在现代网站集(根网站、通信网站和团队网站)上启动,并且没有在 PropertyBag 中设置属性.

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

推荐答案

我通过更改CurrentVersion"的值解决了这个问题字符串,因为属性包不采用整数值.您也可以查看此链接.https://sharepoint.stackexchange.com/questions/171244/setting-propertybag-values-in-sharepoint-online/171247

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

这篇关于如何使用 JSOM 在根网站集的属性包中设置属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆