我正在尝试访问 SharePoint 列表并返回我制作的自定义 Web 部件的日历日期。它工作正常,然后我决定只检索选定的日期而不是整个日历,所以我想添加一个 where 子句。
我已尝试将 'yyyy-MM-dd'、'yyyy-MM-ddThh:mm:ssZ' 和 'yyyy-MM-dd hh:mm:ssZ' 作为字符串格式 我也尝试过 MM/dd/yyyy作为日期格式。
我正在使用 jQuery,并且日历中确实有列表项。我假设我的日期格式不正确。
var date = $(this).attr('date');
var sharepointDate = Date.parse(date).toString('yyyy-mm-ddT00:00:01Z');
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>CorporateCalendar</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
<query><Query><Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'>" + sharepointDate + "</Value></Geq></Where></Query></query> \
<rowLimit>500</rowLimit> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
如果我去掉 where 子句,我会收到日历中的所有项目。如果查询在那里,我不会收到任何结果。
提前致谢
工作代码:
var sharepointDate = Date.parse(date).toString('yyyy-MM-dd');
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>CorporateCalendar</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
<query><Query><Where><Eq><FieldRef Name='EventDate' /><Value Type='DateTime' IncludeTimeValue='False'>" + sharepointDate + "</Value></Eq></Where></Query></query>\
<rowLimit>1500</rowLimit> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";