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 |
|
sharepoint ECMA using a custom contentType to creating a list in
SubSite,布布扣,bubuko.com
sharepoint ECMA using a custom contentType to creating a list in
SubSite