Hi everyone,
recently I've noticed that GetListItems gets all items from the list, including removed ones. It is espessially annoing when you need to compare existing items with the new one. Have anyone noticed the issue? If yes - how can it be resolved? (some additions in the CAML query, maybe?)
here is my code, just in case:
Thanks,
Andrey.
recently I've noticed that GetListItems gets all items from the list, including removed ones. It is espessially annoing when you need to compare existing items with the new one. Have anyone noticed the issue? If yes - how can it be resolved? (some additions in the CAML query, maybe?)
here is my code, just in case:
function verifyDatesOverlap(startDate, endDate)
{
var currentRequestId = getURLParameter('ID');
var employee = $().SPServices.SPGetCurrentUser({fieldName: 'Title',});
startDate = startDate.substring(6,10) + "." + startDate.substring(3,5)+ "." + startDate.substring(0,2);
endDate = endDate.substring(6,10) + "." + endDate.substring(3,5)+ "." + endDate.substring(0,2);
//var date1 = startDate + "T12:00:00Z"; //yyyy-mm-dd
var myQuery = "<Query><Where>"+
"<And>"+
"<Eq>"+
"<FieldRef Name='Requestor' /><Value Type='text'>"+ employee +"</Value>"+
"</Eq>"+
"<DateRangesOverlap>"+
"<FieldRef Name='StartDate'/>"+
"<FieldRef Name='_EndDate'/>"+
"<Value Type='DateTime'><Year /></Value>"+
"</DateRangesOverlap>"+
"</And>"+
"</Where>"+
"</Query>";
var isOverlap = false;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Vacations",
CAMLViewFields: "<ViewFields>"+
"<FieldRef Name='ID' />"+
"<FieldRef Name='Title' />"+
"<FieldRef Name='_EndDate' />"+
"<FieldRef Name='StartDate' />"+
"</ViewFields>",
CAMLQuery: myQuery,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var id = $(this).attr("ows_ID");
var endDate1 = $(this).attr("ows__EndDate");
endDate1 = endDate1.substring(0,10).replace("-", ".").replace("-", ".");
var startDate1 = $(this).attr("ows_StartDate");
startDate1 = startDate1.substring(0,10).replace("-", ".").replace("-", ".");
if(startDate <= endDate1 && startDate1 <= endDate && currentRequestId != id)
{
isOverlap = true;
}
}); //each inside complete function
} //complete function
}); //spservices
return isOverlap ;
};
P.S. I realize this is not the best piece of code, but this is not the question right now :)Thanks,
Andrey.