你好,我嘗試填充特定字段的數組。但我總是得到:The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
我在Sharepoint 2013上,我使用sharepoint的內部名稱。我認爲我的Caml查詢有問題。爲什麼我總是得到該屬性或字段尚未初始化?
這裏是我使用的代碼:
function retrieveListItems(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('MatrixFiles');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><ViewFields><FieldRef Name="LinkFilename" /><FieldRef Name="WebCountry" /><FieldRef Name="WebDepartment" /><FieldRef Name="FileLeafRef" /></ViewFields><Query><OrderBy><FieldRef Name="LinkFilename" /></OrderBy></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 array = [];
var listItemEnumerator = this.collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
console.log(oListItem);
array.push(oListItem);
}
alert(oListItem.get_item('LinkFilename'));
}
奇怪的是該數組被填充SPListItems但是當我嘗試使用警報中的特定字段發生錯誤。不知道爲什麼......
任何幫助將是偉大的,thx爲你的時間。
順便說一句,我用這個SP Caml Query helper。