Your question is not clear. What are you trying to achieve? GetListItems
is to get the list items, not to delete. So if you want to delete items with a WHERE clause you have to call GetListItems
first, and then call UpdateListItems
in providing the ID of the items you want to delete. Is your "itemit" passed to DeleteItems
will return only ONE record from the Basket list?
Your code should look like that :
function DeleteItem(itemid) {
$().SPServices({
operation: "GetListItems",
async: true, /* don't use FALSE ! */
webURL: "MYURL",
listName: "Basket",
CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='Item' /><FieldRef Name='Item:Title' /></ViewFields>",
CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='Item' /><Value Type='Lookup'>" + itemid + "</Value></Eq><Eq><FieldRef Name='Author' /><Value Type='Integer'><UserID /></Value></Eq></And></Where><OrderBy><FieldRef Name='ID' Ascending='FALSE' /></OrderBy></Query>",
completefunc: function (xData, Status) {
// use `.eq(0)` to look at the first one only
$(xData.responseXML).SPFilterNode("z:row").eq(0).each(function() {
alert($(this).attr("ows_ID"));
var ID = $(this).attr("ows_ID");
// now delete it with `UpdateListItems`
$().SPServices({
operation: "UpdateListItems",
webURL: "MYURL",
listName: "Basket",
updates: '<Batch OnError="Continue" ListVersion="1" ViewName=""><Method ID="1" Cmd="Delete"><Field Name='ID'>"+ID+"</Field></Method></Batch>',
completefunc: function (xData, Status) {
alert("OK")
}
});
})
}
})
}
FYI I've created a library that is easier to use: http://aymkdn.github.io/SharepointPlus/
For your code it will look like :
function DeleteItem(itemid) {
// here I suppose that `itemid` will return only one record
$SP().list("Basket").remove({
where:"Item = '"+itemid+"'",
success:function() { alert("Done!") }
})
}