SPUpdateMultipleListItems - No error Status

Dec 2, 2010 at 5:31 PM

I created this function:

function deleteItems() {
	var query = "<Query><Where><Eq><FieldRef Name='ProjectID' /><Value Type='Text'>" + projID + "</Value></Eq></Where></Query>"
	alert(query);
	$().SPServices.SPUpdateMultipleListItems({
		listName: "Action Items",
		CAMLQuery: query,
		batchCmd: "Delete",
		completefunc: function(xData, Status) {
			alert(Status);
		} //completefunc
	}); //SPServices-UpdateMultiItems
} //deleteItems func

but it doesn't delete anything and I don't get an error message back either.  Looking at the CAML, I noticed the column is actually reference with the FieldRef Name of: ProjectID0

I'm not sure why that column is referenced that way, but should I have at least received an alert of the Status?

Coordinator
Dec 2, 2010 at 5:36 PM

Yes, you should see the alert for Status. Are you getting the alert for query?

You don't have a semi-colon after the query definition line. That could be it.

M.

Dec 2, 2010 at 6:46 PM

Yes, I'm getting my alert(query); but it seems as if it's not firing completefunc at all.  I've updated the code to:

function deleteItems() {
	var query = "<Query><Where><Eq><FieldRef Name='ProjectID0' /><Value Type='Text'>" + projID + "</Value></Eq></Where></Query>";
	alert(query);
	$().SPServices.SPUpdateMultipleListItems({
		listName: "Action Items",
		CAMLQuery: query,
		batchCmd: "Delete",
		completefunc: function(xData, Status) {
			alert(Status);
		} //completefunc
	}); //SPServices-UpdateMultiItems
} //deleteItems func

The item(s) are being deleted, so I know it's working now, but it's not handling the completfunc.  The problem before with the delete was the FieldRef Name.  If the completefunc was firing, I would've been prompted, but that wasn't/isn't happening.
What do you think is wrong with my completefunc call?

Coordinator
Dec 2, 2010 at 6:56 PM

It doesn't look like there's anything wrong with your completefunc. I haven't had a chance to try the latest version with the new SPUpdateMultipleListItems function, but I did notice that Marc's documentation (http://spservices.codeplex.com/wikipage?title=$().SPServices.SPUpdateMultipleListItems) doesn't call out completefunc as a supported option for the function. Are you just trying to capture when it's finished? You could do this, though it probably doesn't capture what you want.

function deleteItems() {
	var query = "<Query><Where><Eq><FieldRef Name='ProjectID0' /><Value Type='Text'>" + projID + "</Value></Eq></Where></Query>";
	alert(query);
	$().SPServices.SPUpdateMultipleListItems({
		listName: "Action Items",
		CAMLQuery: query,
		batchCmd: "Delete"
	}); //SPServices-UpdateMultiItems
	alert ('finished');
} //deleteItems func

Dec 2, 2010 at 7:02 PM

Ideally, I'd like to have a completefunc: Status so I know what happened.  This is extremely important for me b/c I'm using a delete operation.  I'd hate to not have a solid error handler for something like this.  All I'm doing is updating the page based on: success or error.  That way if something does go wrong, I can

manually delete the items.  I know it's not supposed to go wrong if I have a valid call to the web service, but it'd be nice to have.

Coordinator
Dec 2, 2010 at 7:05 PM

Agreed. It's certainly best practice to put that error handling in there. Maybe Marc will chime in and confirm if completefunc is supported, though I think he would have told you in his first reply if it wasn't. I can't see anything that's wrong with it.

Coordinator
Dec 3, 2010 at 2:03 AM

Matt:

You know, I just looked, and I'm not giving the option for completefunc in SPUpdateMultipleListItems. (I'd encourage you to dig into the library if you have questions about how a function works.)

I'll add an issue to the issue Tracker for this and get it into the next release.

In the meantime, if you add this code snippet to the end of the function, you can call a completefunc.

  // If present, call completefunc when all else is done
  if(opt.completefunc != null) {
   opt.completefunc();
  }

However, it won't be within the UpdateListItems call. Want to come up with the *right* fix for this?

M.

Coordinator
Dec 3, 2010 at 2:05 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 3, 2010 at 2:38 AM
Edited Dec 3, 2010 at 1:50 PM

You know I'm digging into javascript now more and more, so when I can, I'll add some more drizzle to the Library.  I absolutely love these new capabilities and can't wait to master all of them.  Thanks for looking

into it and the challenge...  I'll see if I can pull it off today.