zoukankan      html  css  js  c++  java
  • 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));
                    }
                }
    }
    此处需要注意的是,必须通过主站点查找到下面的子站点,只有这样才能通过custom contentType 创建成功list



  • 相关阅读:
    基于udp简单聊天的系统
    网络编程_tcp与dup协议简单应用
    logging_modules
    linux内核配置与编译
    linux内核简介
    对于国嵌上学期《一跃进入C大门》Mini2440的代码修正
    通过按键玩中断
    MMU功能解析、深入剖析、配置与使用
    C与汇编混合编程
    一跃进入C大门
  • 原文地址:https://www.cnblogs.com/lynn-lin/p/3775338.html
Copyright © 2011-2022 走看看