Using a list template to creating a list in SubSIte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 |
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) ); }<br> 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) ); } } } } } }<br><br>1.此处需要注意的是,必须通过主站点查找到下面的子站点,只有这样才能通过custom list template 创建成功list<br>2.创建list的必须设置featureID:listCreateInfo.set_templateFeatureId(listTemp.get_featureId().toString());<em id= "__mceDel" >否则会创建不成功,并且报一个Invaild contentType Name错误.</em> |
sharepoint ECMA using a list template to creating a list in SubSIte,布布扣,bubuko.com
sharepoint ECMA using a list template to creating a list in SubSIte
原文:http://www.cnblogs.com/lynn-lin/p/3775344.html