我正在编写一个创建自定义事件列表的应用程序。
我希望在创建列表时启用内容审批(也指后端的审核)。
下面是我的列表创建代码。
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);似乎没有效果。我没有收到任何错误,但是当我查看我使用这段代码创建的列表的设置时,我会看到以下内容:

因此,内容审批显然没有通过我正在使用的方法启用。
发布于 2014-06-18 23:22:53
为了使用Content Approval设置SP.List.enableModeration性质,必须调用SP.List.update()方法,如下所示:
list.set_enableModeration(true);
list.update();https://stackoverflow.com/questions/24289980
复制相似问题