Sharepoint 2010, Below is my CAML query used in javascript. I like to have the 1st FOLDER which is greater or equal to TODAY.
The doclib- view contains a column MeetingDate (type: datetime) which I fill in the date as below. e.g. yesterday it was 28/09/2015. I like to get the folder/row 28/09/2015 selected in my CAML query. But it always took 05/10/2015.
I deleted the 05/10/2015 folder then it took 12/10/2015. I also deleted this folder then it took 28/09/2015 which is good. then I recreated the 2 folders 05/10/15 and 12/10/2015 it kept taking the row/foler 28/09/2015 yesterday which is good.
today is 29/09/2015 when I run the code it takes 28/09/15, which is not good , because in my CAML query I use greather or Equal then...
So there is an issue which I can solve it and don't know what the problem is.
in otherwords it looks like caching and keeping. I deleted all my browsers cache tested on other browsers it's still not correct. I tried with order by in CAML without. change to TRUE/FALSE, with offsetdays, without offsetdays... none are giving other results.... always the same result.
EDIT: I only need 1 row back, the row with meetingdate which is greater than or equal to today's date. so when I run this script today (29/09/2015) it should give me 1 row which is 05/10/2015. Greater than Today and rowlimit =1.
Can someone advice?
e.g.
Name MeetingDate
Folder1 12/10/2015
Folder2 05/10/2015
Folder3 28/09/2015
Folder4 21/09/2015
<View Scope="RecursiveAll">
<Query>
<Where>
<And>
<Eq>
<FieldRef Name="FSObjType" />
<Value Type="Integer">1</Value>
</Eq>
<Geq>
<FieldRef Name="MeetingDate"/>
<Value Type="DateTime">
<Today OffsetDays="-1"/>
</Value>
</Geq>
</And>
</Where>
</Query>
<RowLimit>1</RowLimit>
<OrderBy>
<FieldRef Name="MeetingDate" Ascending ="FALSE"/>
</OrderBy>
</View>
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('DocumentsLIB');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View Scope="RecursiveAll"><Query><Where><And><Eq><FieldRef Name="FSObjType" /><Value Type="Integer">1</Value></Eq><Geq><FieldRef Name="MeetingDate"/><Value Type="DateTime"><Today OffsetDays=-1/></Value></Geq></And></Where></Query><RowLimit>1</RowLimit><OrderBy><FieldRef Name="MeetingDate" Ascending ="FALSE"/></OrderBy></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 folderName = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
folderName = oListItem.get_item('Title');
// I always get 1 record back, which is good, but it's wrong;
}
var urlOfTheDocumentsMT = "http//myurlsite";
document.getElementById("current-documentsmt").href = urlOfTheDocumentsMT + folderName
}