2014-06-18 117 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

因此,內容審批顯然未通過我正在使用的方法啓用。

回答

相關問題