Sharepoint通过模板故障动态生成列表

时间:2019-05-29 18:51:04

标签: javascript sharepoint vuejs2 sharepoint-jsom

我的Sharepoint库中有一个模板,我想在代码中利用该模板。下面的代码生成一个新列表,该列表的名称带有括号(testVard)。但是,这仅在我将listTemplateType保留为genericList时有效。 genericList在我的画廊中不存在,但是可以正常工作。当我用实际存在的模板名称(testVard)替换genericList时,它不起作用。有什么想法Sharepoint偷看吗?我还计划根据输入字段更改文件名--我是否要使它成为计算属性(对于vue开发者)?

<script>

           var clientContext = null;
            var oWeb = null;
            var oListColl = null;
            var oList = null;
            var listCreationInfo = null;
            CreateCustomList();
            function CreateCustomList() {
                clientContext = new SP.ClientContext.get_current();
                oWeb = clientContext.get_web();
                listCreationInfo = new SP.ListCreationInformation();
                listCreationInfo.set_title('testVard');
                listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
                oList = oWeb.get_lists().add(listCreationInfo);
                clientContext.load(oList);
                clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
            }
            function onQuerySucceeded() {
                alert(oList.get_title() + ' created successfully.');
            }
            function onQueryFailed(sender, args) {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
            }         
    </script>
<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/SP.RequestExecutor.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>

0 个答案:

没有答案