I want to delete a list element using CAML Query.
The element has the value 55
in the column CorrespondingListID
.
This is the function I use:
deleteFromHistory: function(){
console.log("deleteFromHistory called!")
let siteUrl = 'https://basketballulm1.sharepoint.com/sites/Playercard/';
let clientContext = new SP.ClientContext(siteUrl);
let oList = clientContext.get_web().get_lists().getByTitle('History');
let camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'CorrespondingListID\'/>' +
'<Value Type=\'Text\'>55</Value></Eq></Where></Query></View>');
var collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
console.log("collListItem: " + collListItem);
var oListItem = collListItem.itemAt(1);
console.log("oListItem: " + oListItem);
oListItem.deleteObject();
console.log("itemAt(1");
//Execute the query
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded2), Function.createDelegate(this, this.onQueryFailed2));
},
The problem I have is that it tells me that deleteObject
is undefined:
I've tried for hours, but I can't figure out what the problem is.
var oListItem = collListItem.itemAt(0);
doesn't exist either, so maybe there's something wrong with the CAML query?
Can someone tell me what I did wrong?
Thanks in advance!