Following is my code...
以下是我的代码......
function retrieveListItems() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('list name');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'ID\'/>' + < Value Type = \'Integer\'>413</Value></Eq></Where></Query></View>');
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo += 'Title: ' + oListItem.get_item('Writer').get_lookupValue();
}
alert(listItemInfo.toString());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
I even tried with oListItem.get_item('Writer').get_title()
but it is not working.. Sometime it returns undefined... Please help..
我甚至尝试过使用oListItem.get_item('Writer')。get_title()但它无法工作..有时候它会返回undefined ...请帮忙..
1 个解决方案
#1
If you are looking for list item 'Created By' value then use 'Author' instead of 'Writer' or if you want 'Modified By' value then use 'Editor' instead of 'Writer'.
如果您要查找列表项“创建者”值,则使用“作者”而不是“作者”或如果您想要“修改者”值,则使用“编辑器”而不是“编写器”。
#1
If you are looking for list item 'Created By' value then use 'Author' instead of 'Writer' or if you want 'Modified By' value then use 'Editor' instead of 'Writer'.
如果您要查找列表项“创建者”值,则使用“作者”而不是“作者”或如果您想要“修改者”值,则使用“编辑器”而不是“编写器”。