SP へContentTypeCollection オブジェクト (sp.js)
ワークフローの関連付けによって使用されるワークフロー履歴リストを指定する値を取得または設定します。
**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.ContentTypeCollection()
メンバー
ContentTypeCollectionオブジェクトでは、次のメンバーがあります。
Constructor
ContentTypeCollectionオブジェクトでは、次のコンスがあります。
コンストラクター |
説明 |
---|---|
Initializes a new instance of the SP.ContentTypeCollection object. |
メソッド
ContentTypeCollectionオブジェクトでは、次の方法があります。
メソッド |
説明 |
---|---|
Adds a new content type to the collection. |
|
Adds the specified content type to the collection. |
|
Returns the content type with the specified ID from the collection. |
|
Gets the element at the specified index of the collection. |
プロパティ
ContentTypeCollectionオブジェクトでは、次のプロパティがあります。
プロパティ |
説明 |
---|---|
Gets the element at the specified index of the collection. |
例
次の例では、ユーザー設定のコンテンツ タイプを初期化、コンテンツの種類のコレクションに追加し、現在の Web サイトのコンテンツ タイプの名前を表示するアプリケーション ページの [入力] ボタンを作成します。
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">
var contentTypeCollection;
function runCode() {
var clientContext = new SP.ClientContext.get_current();
if (clientContext != undefined && clientContext != null) {
var webSite = clientContext.get_web();
this.contentTypeCollection = webSite.get_contentTypes();
// Initialize a new content type.
var contentInfo = new SP.ContentTypeCreationInformation();
contentInfo.set_name('myContentType2');
contentInfo.set_description('My custom content type 2');
this.contentTypeCollection.add(contentInfo);
clientContext.load(this.contentTypeCollection);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onQuerySucceeded() {
var contentTypeinfo = '';
var contentTypeEnumerator = this.contentTypeCollection.getEnumerator();
while (contentTypeEnumerator.moveNext()) {
var content = contentTypeEnumerator.get_current();
contentTypeinfo += 'Content Type Name: ' + content.get_name() + '\n';
}
alert(contentTypeinfo);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
<input id="Button1" type="button" value="Run Code" onclick="runCode()" />
</asp:Content>
他のリソースのエンドポイント
エンドポイント URI 構造
http://<sitecollection>/<site>/_api/web/lists(listid)/contenttypes
HTTP 要求
このリソースには、次の HTTP コマンドがサポートしています。
書式を取得します。
GET http://<sitecollection>/<site>/_api/web/lists(listid)/contenttypes
投稿の書式
POST http://<sitecollection>/<site>/_api/web/lists(listid)/contenttypes