首页 > 代码库 > sharepoint ECMA using a custom contentType to creating a list in SubSite
sharepoint ECMA using a custom contentType to creating a list in SubSite
Using a custom contentType to creating a list:
function GetContentType() { var clientContext = new SP.ClientContext(siteUrl); var currentWeb = clientContext.get_web(); var contentTypeCollection = currentWeb.get_contentTypes(); var contentType = contentTypeCollection.getById("0x01010038CBF7FA14024D2688184E50E84E3239"); clientContext.load(contentType); clientContext.executeQueryAsync( Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed) ); } function onQuerySucceeded(){ var count = subWebs.get_count(); if (count > 0) { for (var i = 0; i < count; i++) { var subWeb = subWebs.itemAt(i); var list = subWeb.get_lists().getByTitle("12"); //get this list all contentType var sublistContentTypeCollection = list.get_contentTypes(); //if this contentType is no add this contentType; sublistContentTypeCollection.addExistingContentType(contentType); clientContext.load(subWeb); clientContext.load(list); clientContext.load(sublistContentTypeCollection); clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceededContentType), Function.createDelegate(this, onQueryFailedContentType)); } } }
?
1 | 此处需要注意的是,必须通过主站点查找到下面的子站点,只有这样才能通过custom contentType 创建成功list |
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。