我正在尝试从显示模板上的共享点列表项中获取所有字段值,ctx.CurrentItem 仅获取一些值,但不是我需要的全部。
我尝试了以下代码,但标题出现错误
SyntaxError:无法在“文档”上执行“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);
}