我有一个Sharepoint列表,还有一些文件夹。我需要使用JavaScript来获取这些文件夹的内容,并且最好只选择一个文件夹,即AddData日期列等于当前日期。我想请你帮忙。我唯一能做到的就是:
context = SP.ClientContext.get_current();
var web = context.get_web();
list = context.get_web().get_lists().getByTitle("ExchangeRateList");
var camlString =
"<View><ViewFields>" +
"<FieldRef Name='Title' />" +
"<FieldRef Name='Modified' />" +
"<FieldRef Name='Created' />"+
"</ViewFields></View>";
var camlQuery = new SP.CamlQuery();
camlQuery.View
camlQuery.set_viewXml(camlString);
allAnnouncements = list.getItems(camlQuery);
var enumerator = allAnnouncements.getEnumerator();
while (enumerator.moveNext()) {
var announcement = enumerator.get_current();
var title = announcement.get_item("Title")
...
公告是我的文件夹,但如何从此文件夹中获取项目?并检查AddData列?
答案 0 :(得分:0)
Scope="RecursiveAll"
设置View element
以包含项目
文件夹(S)<View Scope="RecursiveAll">
<Query>
<Where>
<Eq>
<FieldRef Name="AddData" />
<Value Type="DateTime">
<Today />
</Value>
</Eq>
</Where>
</Query>
</View>
var listTitle = 'Announcements';
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle(listTitle);
var listItems = list.getItems(createQuery());
context.load(listItems);
context.executeQueryAsync(
function() {
var c = listItems.get_count();
for(var i = 0; i< c;i++ ) {
var listItem = listItems.getItemAtIndex(i);
console.log(listItem.get_item('Title'));
//...
}
},
function(sender,args){
console.log(args.get_message());
}
);
function createQuery()
{
var qry = new SP.CamlQuery();
qry.set_viewXml('<View Scope="RecursiveAll"> \
<Query> \
<Where> \
<Eq> \
<FieldRef Name="AddData" /> \
<Value Type="DateTime"> \
<Today /> \
</Value> \
</Eq> \
</Where> \
</Query> \
</View>');
return qry;
}