Alpha download v0.6

Dec 28, 2010 at 2:21 PM

I'm trying to get the completfunc to post back it's normal: success || error.  With the function below, I'm able to delete the items, but the alert firing is stating that Status is: undefined.  What do you think is going on here?  I should also note

resetPage(Status); is firing and working as expected.  I'm just not getting a Status that I would expect.

 

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

Thanks for your time.

Dec 28, 2010 at 2:30 PM

Where's projID coming from?

Have you tried async: false?

Have you tried putting the alert after resetPage?

I'm just thinking you're checking the Status before the function completes....

 

Coordinator
Dec 28, 2010 at 2:33 PM

The completefunc that I added fires after the updates are complete, outside the UpdateListItems call. Now that I look at this in the light of day, it's not all that useful. ;=)

  // Call UpdateListItems to update all of the items matching the CAMLQuery
  $().SPServices({
   operation: "UpdateListItems",
   async: false,
   webURL: opt.webURL,
   listName: opt.listName,
   updates: batch,
   completefunc: function(xData, Status) {
   }
  });
  // If present, call completefunc when all else is done
  if(opt.completefunc != null) {
   opt.completefunc();
  }
I think it would make more sense to do this:
// Call UpdateListItems to update all of the items matching the CAMLQuery
  $().SPServices({
   operation: "UpdateListItems",
   async: false,
   webURL: opt.webURL,
   listName: opt.listName,
   updates: batch,
   completefunc: function(xData, Status) {
  // If present, call completefunc when all else is done
  if(opt.completefunc != null) {
   opt.completefunc();
  }
   }
  });
Try altering your copy and see if that lets you do what you want. If so, I'll update.
M.
Dec 28, 2010 at 3:33 PM

I changed the SPServices code to:

 

		// Call UpdateListItems to update all of the items matching the CAMLQuery
		$().SPServices({
			operation: "UpdateListItems",
			async: false,
			webURL: opt.webURL,
			listName: opt.listName,
			updates: batch,
			completefunc: function(xData, Status) {
				if(opt.completefunc != null) {
					opt.completefunc();
				}
			}
		});
	};// End of function SPUpdateMultipleListItems

 

and Status is still: undefined.

@JBHoward; I have a bunch of other functions that are finally calling this last function: deleteItems().  projID is a global variable I'm using that is set via an inputbox.  The alert I have in resetPage() is also alerting Status as: undefined.  I did change the deleteItems() call to this:

function deleteItems(listName, strColumnName) {
	
	//CAML for item query
	var query = "<Query><Where><Eq><FieldRef Name='" + strColumnName + "' /><Value Type='Text'>" + projID + "</Value></Eq></Where></Query>";
	
	//Delete items matching query
	$().SPServices.SPUpdateMultipleListItems({
		async: false,
		listName: listName,
		CAMLQuery: query,
		batchCmd: "Delete",
		completefunc: function(xData, Status) {
			deleteItemsStatus = Status;
			alert(Status);
			resetPage(Status); //Can delete
		} //completefunc
	}); //SPServices-UpdateMultiItems
} //deleteItems func

Any more ideas you guys want me to try?  I'm getting close to exactly what I need, so as soon as completefunc quits acting funky, I'll have something pretty cool.

Cheers,

Matt

Coordinator
Jan 4, 2011 at 1:07 PM

I dropped the ball on this. Where are you on it?

M.

Jan 4, 2011 at 2:56 PM

I'm still at the same spot.  The Status of the completefunc returns: undefined.  However, all of the items I send through the function are deleted.  So, I'm thinking it has to do with something inside code of SPServices

throwing off the completefunc.  I tried debugging it, but I'm nowhere near your skills with javascript.  

 

I can get you the full code that I'm using if you need it.

Cheers,

Matt

Coordinator
Jan 4, 2011 at 7:05 PM

Yeah, it would help to see at least the completefunc you are passing in.

M.