2017-07-25 2 views
1

SharePointの月間アプリケーションでこのクエリを使用しています。しかし、私はちょうど私が取得しようとしている週に7月31日から8月4日のような分割された月がある場合、それは7月31日のためのリスト項目を返すだろうことに気づいた???私はこれを働かせるために何も考えずに何も考えなかった。どうすればそれを動作させることができますか?私は迷っている。 daterangeオーバーラップタグを使って試してみましたが、それは単にクエリに失敗し、考えられる日付の他のすべてのフォーマットを試して、空の列挙子を返します。 MSDNから何時間も検索されましたが、この問題に関するヘルプはありませんでした。数時間Googleとスタックのオーバーフローが検索されましたが、この質問に対する回答は見つかりませんでした。それはCAMTクエリが機能しない週が分割された月、つまり31st-4番目のみ返される31st

startDate = startDate.toISOString(); 
 
    endDate = endDate.toISOString(); 
 
    
 
    var camlQuery = new SP.CamlQuery(); 
 
    var filterString = '<View><Query>'; 
 
    filterString = filterString + '<Where>'; 
 
    filterString = filterString + '<And>'; 
 
    filterString = filterString + '<Geq>'; 
 
    filterString = filterString + '<FieldRef Name=\'EstimatedDelivery\'/>'; 
 
    filterString = filterString + '<Value IncludeTimeValue=\'TRUE\' Type = \'DateTime\'>' + startDate + '</Value>'; 
 
    filterString = filterString + '</Geq>'; 
 
    filterString = filterString + '<Leq>'; 
 
    filterString = filterString + '<FieldRef Name=\'EstimatedDelivery\'/>'; 
 
    filterString = filterString + '<Value IncludeTimeValue=\'TRUE\' Type = \'DateTime\'>' + endDate + '</Value>'; 
 
    filterString = filterString + '</Leq>'; 
 
    filterString = filterString + '</And>'; 
 
    filterString = filterString +'</Where>'; 
 
    filterString = filterString + '</Query></View>';
<View> 
 
     <Query> 
 
     <Where> 
 
      <And> 
 
      <Geq> 
 
       <FieldRef Name='EstimatedDelivery'/> 
 
       <Value IncludeTimeValue='TRUE' Type='DateTime'>startDate</Value> 
 
      </Geq> 
 
      <Leq> 
 
       <FieldRef Name='EstimatedDelivery'/> 
 
       <Value IncludeTimeValue='TRUE' Type='DateTime'>endDate</Value> 
 
      </Leq> 
 
      </And> 
 
     </Where> 
 
     </Query> 
 
    </View>

答えて

2

を除くすべての私のquerysにだけで正常に動作しCAMLは2ヶ月に分割されている週に失敗した理由を誰も把握することはできませんようですので、残りのコールにCAMLのクエリを変更し、今はすべてが動作し、約12倍高速です!

var url = "/_api/web/lists/getbytitle('ListName')/Items?" + 
     "$orderby=EstimatedDelivery&$filter=EstimatedDelivery ge datetime'" 
+ startDate + "' and EstimatedDelivery le datetime'" + endDate + "'"; 

getItems(url, retrieveCalendarListItemsSucceeded); 

function getItems(url, callback) { 
    $.ajax({ 
     url: _spPageContextInfo.webAbsoluteUrl + url, 
     type: "GET", 
     headers: { 
      "accept": "application/json;odata=verbose", 
     }, 
     success: function (data) { 
      callback(data.d.results); 
     }, 
     error: function (error) { 
      alert(JSON.stringify(error)); 
     } 
    }); 
} 
関連する問題