// コンテキスト取得
var custCtx = SP.ClientContext.get_current();
// サイトオブジェクト取得指示
var custWeb = custCtx.get_web();
// リスト(ライブラリ) オブジェクトの取得指示
var custList = custCtx.get_web().get_lists().getByTitle("(リスト・ライブラリの表示名)");
//// リストコンテキスト内のページ(ビュー、フォーム等)の場合に現在のリストを取得する場合
//var custList = custCtx.get_web().get_lists().getById(_spPageContextInfo.pageListId);
// リストオブジェクト取得予約
custCtx.load(custList);
// サーバーへのクエリー実行(ここまでのコンテキストに含まれる指示予約を送信)
custCtx.executeQueryAsync(
function(sender, args) { // クエリー実行時コールバック処理
console.log(custList);
// ここで各種処理
},
function(sender, args) { // クエリー失敗時コールバック処理
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
);
More than 5 years have passed since last update.
SharePoint Client Object Model でリスト オブジェクトを取得するコード
Posted at
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme