表示テンプレートの sharepoint リスト アイテムからすべてのフィールド値を取得しようとしています。
次のコードを試しましたが、タイトルにエラーが表示されます
SyntaxError: 'Document' で 'querySelector' を実行できませんでした: '[object HTMLDocument]' は有効なセレクターではありません。
function GetListItemById_Success(sender, args)
{
var id = ListItem.get_id();
var title = ListItem.get_item("Title");
alert("Updated List Item: \n Id: " + id + " \n Title: " + title);
}
// Display an appropriate error message
function GetListItemById_Fail(sender, args)
{
alert("GetListItemById Failed. \n" + args.get_message() + "\n" + args.get_stackTrace());
}
$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(CustomAction, "sp.js"); });
function CustomAction(){
var clientContext = new SP.ClientContext.get_current();
var web = clientContext .get_web();
var targetList = clientContext.get_web().get_lists().getByTitle('Test Document Library');
var list = web.get_lists().getByTitle('Test Document Library');
ListItem = list.getItemById(ctx.CurrentItem.DocId);
clientContext.load(ListItem, "Id", "Title");
clientContext.executeQueryAsync(GetListItemById_Success, GetListItemById_Fail);
}