SPUpdateMultipleListItems not working for me

Mar 5, 2012 at 4:59 PM
Edited Mar 5, 2012 at 5:00 PM

I'm extremely confused as to why I can't get SPUpdateMultipleItems working. If commented out, the script works fine, with it uncommented, the script doesn't return the alert text:



Nothing returned. 3 Alerts not returned

<script type="text/javascript">
$(document).ready(function(){
 
 alert ("1");
 
 $("#btnPublishAll").click(function(){
 
  alert ("2");
          
  $().SPServices.SPUpdateMultipleListItems({
  
   alert ("3");
   
   var title = $("input[Name='Title").val();
   //webURL: "", current site used
   listName: "{625250E0-EF95-462E-96C2-A2F47AF86719}", //Contact RelatedDocs (Uploaded docs)
   CAMLQuery: "",  //none
   batchCmd: "Update",
   valuepairs: ["Comments",title],
   debug: true,
   completefunc: null
   });                                                          
   }); // end click
});

</script>

<p><input type="button" id="btnPublishAll" value="Update" /></p>


Returns all 2 alerts because SPUpDateMultipleItems is commented out. 

<script type="text/javascript">

$(document).ready(function(){
 
 alert ("1");
 
 $("#btnPublishAll").click(function(){
 
  alert ("2");
          
//  $().SPServices.SPUpdateMultipleListItems({
  
//   alert ("3");
   
//   var title = $("input[Name='Title").val();
   //webURL: "", current site used
//   listName: "{625250E0-EF95-462E-96C2-A2F47AF86719}", //Contact RelatedDocs (Uploaded docs)
//   CAMLQuery: "",  //none
//   batchCmd: "Update",
//   valuepairs: ["Comments",title],
//   debug: true,
//   completefunc: null
//   });                                                           
   }); // end click
});  

</script>

<p><input type="button" id="btnPublishAll" value="Update" /></p>

 

Anyone know what I may be doing wrong? I've been testing this for >4 hours and am stymied.

Thanks

CW


Mar 5, 2012 at 7:45 PM

It looks like you have a syntax error here. Try adding a single quote between Title and the second double quote.

var title = $("input[Name='Title").val();

From: Carlw [email removed]
Sent: Monday, March 05, 2012 5:00 PM
To: steve.eagleson@sky.com
Subject: SPUpdateMultipleListItems not working for me [SPServices:347371]

From: Carlw

I'm extremely confused as to why I can't get SPUpdateMultipleItems working. If commented out, the script works fine, with it uncommented, the script doesn't return the alert text:



Nothing returned. 3 Alerts not returned

<script type="text/javascript">
$(document).ready(function(){

alert ("1");

$("#btnPublishAll").click(function(){

alert ("2");

$().SPServices.SPUpdateMultipleListItems({

alert ("3");

var title = $("input[Name='Title").val();
//webURL: "", current site used
listName: "{625250E0-EF95-462E-96C2-A2F47AF86719}", //Contact RelatedDocs (Uploaded docs)
CAMLQuery: "", //none
batchCmd: "Update",
valuepairs: ["Comments",title],
debug: true,
completefunc: null
});
}); // end click
});

</script>

<input type="button" id="btnPublishAll" value="Update" />


Returns all 2 alerts because SPUpDateMultipleItems is commented out.

<script type="text/javascript">

$(document).ready(function(){

alert ("1");

$("#btnPublishAll").click(function(){

alert ("2");

// $().SPServices.SPUpdateMultipleListItems({

// alert ("3");

// var title = $("input[Name='Title").val();
//webURL: "", current site used
// listName: "{625250E0-EF95-462E-96C2-A2F47AF86719}", //Contact RelatedDocs (Uploaded docs)
// CAMLQuery: "", //none
// batchCmd: "Update",
// valuepairs: ["Comments",title],
// debug: true,
// completefunc: null
// });
}); // end click
});

</script>

<input type="button" id="btnPublishAll" value="Update" />


Anyone know what I may be doing wrong? I've been testing this for >4 hours and am stymied.

Thanks

CW

Coordinator
Mar 6, 2012 at 12:25 AM
Edited Mar 6, 2012 at 1:01 AM

Actually, a little more:

var title = $("input[Name='Title']").val();

M.

Mar 6, 2012 at 1:49 PM

Thanks gents, however, even without that syntax error, it's still apparent that anytime the SPUpDateMultipleListItems function is uncommented, nothing in the rest of the function works. In the following example, none of the alerts fire because the SPUpDateMultipleListItems function is uncommented.


 <script type="text/javascript">

$(document).ready(function(){
 
 $("#btnPublishAll").click(function(){
 
  alert ("2");
          
  $().SPServices.SPUpdateMultipleListItems({
  
   alert ("testing123");
   
//   var title = $("input[Name='Title']").val();

   //alert (title);
   //webURL: "", current site used
//   listName: "{625250E0-EF95-462E-96C2-A2F47AF86719}", //Contact RelatedDocs (Uploaded docs)
//   CAMLQuery: "",  //none
//   batchCmd: "Update",
//   valuepairs: ["Comments",title],
//   debug: true,
//   completefunc: null
   });                                                          
   }); // end click
});  

</script>

<p><input type="button" id="btnPublishAll" value="Update" /></p>


Meanwhile, commenting it out again, the alert ("2"); fires on-click:


<script type="text/javascript">

$(document).ready(function(){
 
 $("#btnPublishAll").click(function(){
 
  alert ("2");
          
//  $().SPServices.SPUpdateMultipleListItems({
  
//   alert ("3");
   
//   var title = $("input[Name='Title']").val();

   //alert (title);
   //webURL: "", current site used
//   listName: "{625250E0-EF95-462E-96C2-A2F47AF86719}", //Contact RelatedDocs (Uploaded docs)
//   CAMLQuery: "",  //none
//   batchCmd: "Update",
//   valuepairs: ["Comments",title],
//   debug: true,
//   completefunc: null
//   });                                                           
   }); // end click
});  

</script>

<p><input type="button" id="btnPublishAll" value="Update" /></p>


Cheers again

CW

I'd really love to get this working as it's a pretty slick tool tool accomplish alot. Should I try out the other (older?) UpdateListItems function ? BTW, I do have both the jQuery and SPServices referenced in my default.master page right under placeholdermain.

I'm using jQuery v1.7.1 and SPServices Version 0.7.1a

Coordinator
Mar 6, 2012 at 1:58 PM

Are you sure the script reference to SPServices is valid?

Try these alerts: http://sympmarc.com/2011/07/08/adding-jqueryspservices-to-a-sharepoint-page-step-one-always/

M.

Mar 6, 2012 at 2:32 PM

Hi Marc. I know this is not what you expected to hear but, yes, both alerts are returned. Depending on where they are placed. 

However, with SPUpDateMultipleItems simply uncommented and only the alerts available, the click doesn't return any alerts.

......
$().SPServices.SPUpdateMultipleListItems({
  
   alert("jQuery");
   alert($().SPServices.SPGetCurrentSite());
......
});
......

Yet, if the alerts are out side the SPUpDateMultipleListItems function, then the alerts you recommended are returned

......
   alert("jQuery");
   alert($().SPServices.SPGetCurrentSite());

$().SPServices.SPUpdateMultipleListItems({
  
});
......

Wierd. Perhaps the function is suffering from "Carlitis"? i.e: I'm trying to use it so now it won't work.

CW

Mar 7, 2012 at 1:46 AM

cw,
The code you posted for how you are using this utility is not valid... You can't call functions from inside an object definition({...})... In your example, you need to define your input to SPUpdateMulitpleListItems() inside the Click event function, but outside of the call to SPUdateMultipleListItems()... I would strongly suggest that you read the documentation for this tool and look for a few examples in the forums...

Try this (from your original post):


$(document).ready(function(){
alert ("1... Ready() done");
$("#btnPublishAll").click(function(){

alert ("2... Click() done.");
var title = $("input[Name='Title").val();

$().SPServices.SPUpdateMultipleListItems({
listName: "{625250E0-EF95-462E-96C2-A2F47AF86719}", //Contact RelatedDocs (Uploaded docs)
CAMLQuery: "", //none
batchCmd: "Update",
valuepairs: ["Comments",title],
debug: true,
completefunc: function(){
alert("SPUdateMultipleListItems() has executed successfully!!!!");
}
});
}); // end click

});



Note that I have never used this tool before, so I don't know if the CAMLQuery param is optional (you did not have it defined)... Please check the documentation.

Paul

Sent from mobile