0
我一直在抨擊這個問題,並在網上無處不在尋找答案。我希望有人能幫幫忙!Sharepoint 365:獲取列表中的所有項目(但表示列不存在!)
我想要做的就是在Sharepoint Online 365中查詢一個列表,並返回該列表中的所有項目及其列值。
問題是,當我嘗試列出我想包括的列時,我知道這個列存在,我得到一個錯誤,說他們不存在!
我可以成功檢索「標題」和項目的ID。就這樣。沒有自定義列。
任何人都知道爲什麼?!?
<script type="text/javascript">
/*Below line will make sure your JavaScript method will be called only after the SP.js file loaded at the client side*/
window.onload = QueryFollowUrl;
function QueryFollowUrl()
{
//Gets the Client context of the Web
var context = new SP.ClientContext.get_current();
var web = context.get_web();
//Change the List Name with yours
this.list = web.get_lists().getByTitle('Team Projects');
var camlQuery = new SP.CamlQuery();
//Reframe the Caml query as per your requirements
var query = "<View><ViewFields><FieldRef Name='Title' /><FieldRef Name='Details' /><FieldRef Name='Status' /></ViewFields></View>";
camlQuery.set_viewXml(query);
listItems = this.list.getItems(camlQuery);
context.load(list);
/*Now mention all the required filed internal name, since data from these fields only will be retrieved*/
context.load(listItems, 'Include(Title, Details, Status)');
//Makes asynchronous call to the Server, which will return the JSON objects
context.executeQueryAsync(Function.createDelegate(this, this.successFollow), Function.createDelegate(this, this.failedFollow));
return false;
}
//you can get the Error details if your Execution fails using get_message() method
function failedFollow(sender, args)
{
var errorMsg = args.get_message();
document.getElementById('projects').innerHTML = errorMsg;
}
/*Upon successful execution, Success delegate method will be called and all the requested objects will the loaded with contents*/
function successFollow(sender, args)
{
var ListEnumerator = this.listItems.getEnumerator();
while (ListEnumerator.moveNext())
{
var collection = ListEnumerator.get_current();
/*Using get_item method you can pass the Field Internal name mentioned earlier and get the data in that respective column, if you try to use any other column other than we mentioned earlier, it will throw you error.*/
var itemTitle = collection.get_item('Title');
document.getElementById('projects').innerHTML += itemTitle+' '+itemDetails+'<br>';
//your code here
}
}
</script>
<h2>Current Projects (loaded using Javascript from the 'Team Projects' list)</h2>
<div id="projects"></div>
在實際的網址?它說「Field = e72u」....所以這個字段實際上被命名爲「e72u」?很奇怪。 –
我想你已經在列表的快速編輯模式視圖中使用「添加列」鏈接創建了該字段。它會在名稱中創建包含一些隨機字符('e72u ..')的字段,然後更改其顯示名稱。 – vijayata