2014-06-18 19 views
1

我正在编写一个可创建自定义事件列表的应用程序。以编程方式在SharePoint列表中启用内容审批(审核)

我想在创建列表时启用内容审批(在后端也称为审核)。

这是我的列表创建代码的样子。

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);没有效果。我没有收到任何错误,但是当我查看使用此代码创建的列表的设置时,我看到: enter image description here

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

回答

相关问题