首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SharePoint列表中以编程方式启用内容审批(审核)

在SharePoint列表中以编程方式启用内容审批(审核)
EN

Stack Overflow用户
提问于 2014-06-18 15:51:27
回答 1查看 1.7K关注 0票数 1

我正在编写一个创建自定义事件列表的应用程序。

我希望在创建列表时启用内容审批(也指后端的审核)。

下面是我的列表创建代码。

代码语言:javascript
复制
    function createList(listToCreate)
{
    // Create a SharePoint list with the name that the user specifies.
    var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    var hostContext = new SP.AppContextSite(currentContext, hostUrl);
    var hostweb = hostContext.get_web();
    var listCreationInfo = new SP.ListCreationInformation();

    //title the list
    listCreationInfo.set_title(listToCreate);

    //set the base type of the list
    listCreationInfo.set_templateType(SP.ListTemplateType.events);

    var lists = hostweb.get_lists();
    //use the creation info to create the list
    var newList = lists.add(listCreationInfo);

    var fieldCollection = newList.get_fields();

    //add extra fields (columns) to the list & any other info needed.
    fieldCollection.addFieldAsXml('<Field Type="User" DisplayName="Requester" Name="Requester" />', true, SP.AddFieldOptions.AddToDefaultContentType);
    fieldCollection.addFieldAsXml('<Field Type="User" DisplayName="Manager" Name="Manager" />', true, SP.AddFieldOptions.AddToDefaultContentType);
    fieldCollection.addFieldAsXml('<Field Type="Boolean" DisplayName="Approved" Name="Approved" />', true, SP.AddFieldOptions.AddToDefaultContentType);

    //Attempting to enable moderation. This doesn't seem to have any effect.
    newList.set_enableModeration(true);

    currentContext.load(fieldCollection);
    currentContext.load(newList);
    currentContext.executeQueryAsync(onListCreationSuccess, onListCreationFail);     
}

function onListCreationSuccess() {
    alert("We've created a list since one didn't exist yet. Look in the site that hosts this app for the list." );
}

function onListCreationFail(sender, args) {
    //alert("We didn't create the list. Here's why: " + args.get_message());
}

不幸的是,.set_enableModeration(true);似乎没有效果。我没有收到任何错误,但是当我查看我使用这段代码创建的列表的设置时,我会看到以下内容:

因此,内容审批显然没有通过我正在使用的方法启用。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-18 23:22:53

为了使用Content Approval设置SP.List.enableModeration性质,必须调用SP.List.update()方法,如下所示:

代码语言:javascript
复制
list.set_enableModeration(true);
list.update();
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24289980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档