zoukankan      html  css  js  c++  java
  • sharepoint ECMA using a list template to creating a list in SubSIte

    Using a list template to creating a list in SubSIte

    function CreateList(){
            var clientContext = new SP.ClientContext(siteUrl);
            var currentWeb = clientContext.get_web();
            var listTemplateCollection = currentWeb.get_listTemplates();
                clientContext.load(listTemplateCollection);
                clientContext.executeQueryAsync(
                    Function.createDelegate(this, onQuerySucceededlistTemplate),
                    Function.createDelegate(this, onQueryFailedlistTemplate)
                );
    }
    function onQuerySucceededlistTemplate() { var listTemplateEnumerator = listTemplateCollection.getEnumerator(); var listtemplateInfo = ""; while (listTemplateEnumerator.moveNext()) { var listTemp = listTemplateEnumerator.get_current(); if (listTemp.get_name() == "OfficeDocument_List") { var count = subWebs.get_count(); if (count > 0) { for (var i = 0; i < count; i++) { var subWeb = subWebs.itemAt(i); if (subWeb.get_serverRelativeUrl() == self.selectedSiteName()) { var listCreateInfo = new SP.ListCreationInformation(); listCreateInfo.set_title(self.DocumentName()); listCreateInfo.set_description(self.DocumentDescription()); listCreateInfo.set_templateType(listTemp.get_listTemplateTypeKind()); listCreateInfo.set_templateFeatureId(listTemp.get_featureId().toString()); oList = subWeb.get_lists().add(listCreateInfo); clientContext.load(subWeb); clientContext.load(oList); clientContext.executeQueryAsync( Function.createDelegate(this, ExecuteOnSuccessList), Function.createDelegate(this, ExecuteOnFailureList) ); } } } } } }

    1.此处需要注意的是,必须通过主站点查找到下面的子站点,只有这样才能通过custom list template 创建成功list
    2.创建list的必须设置featureID:listCreateInfo.set_templateFeatureId(listTemp.get_featureId().toString());否则会创建不成功,并且报一个Invaild contentType Name错误.

      

  • 相关阅读:
    基于Modelsim的直方图线性拉伸
    基于Modelsim的直方图统计算法仿真
    基于Modelsim的均值滤波仿真
    基于Modelsim的直方图均衡化算法仿真
    基于FPGA的RGB图像转灰度图像算法实现
    基于Modelsim的视频捕获模拟仿真
    基于Modelsim的视频流仿真
    【MSSQL】执行大sql文件-内容乱码处理
    【WINForm】C#应用程序图标设置问题
    【dotNet Core】Swagger下简单的给WebApi分组
  • 原文地址:https://www.cnblogs.com/lynn-lin/p/3775344.html
Copyright © 2011-2022 走看看