【问题标题】:How to disable SharePoint 2013 alerts using CSOM如何使用 CSOM 禁用 SharePoint 2013 警报
【发布时间】:2020-11-12 16:35:58
【问题描述】:

使用 CSOM,我能够检索 SharePoint Online 网站的警报集合,并使用以下代码禁用每个警报:

                    context.Load(context.Web.Alerts,
                        collection => collection.Include(
                            alert => alert.ID,
                            alert => alert.Status));
                    context.ExecuteQueryWithRetry();

                    foreach (SP.Alert alert in context.Web.Alerts)
                    {
                        if (alert.Status == AlertStatus.On)
                        {
                            context.Load(alert);
                            alert.Status = AlertStatus.Off;
                            alert.UpdateAlert();
                        }
                    }
                    context.ExecuteQueryWithRetry();

但这不适用于 SharePoint 2013。我收到错误消息:“字段或属性‘警报’不存在”。这可以通过 CSOM 完成吗?

【问题讨论】:

    标签: sharepoint csom alerts


    【解决方案1】:

    How to disable SharePoint 2013 alerts using CSOM相同的问题

    SharePoint 2013 本地 CSOM Web 对象不支持警报属性。

    请改用下面的 SharePoint Server 对象模型:

            using (SPSite site=new SPSite("http://sp/sites/MyDev"))
            {
                SPWeb web = site.OpenWeb();
                SPAlertCollection alerts = web.Alerts;
                foreach (SPAlert alert in alerts)
                {
                    alert.Status = SPAlertStatus.Off;
                    alert.Update();
                    web.Update();
                }
            }
    

    【讨论】:

    猜你喜欢
    • 2017-04-04
    • 1970-01-01
    • 1970-01-01
    • 2013-06-08
    • 2017-09-16
    • 2021-02-27
    • 2015-06-22
    • 1970-01-01
    • 2015-12-13
    相关资源
    最近更新 更多