change content type in SPServices.SPUpdateMultipleListItems

Jul 25, 2011 at 11:42 AM

Hi all,

Been trying to change a content type in the SPServices.SPUpdateMultipleListItems function.

Changing metadata works perfectly, but changing the content type in the valuepairs does not seem to work.

Any ideas ?

 

used code:

 $().SPServices.SPUpdateMultipleListItems({  listName: "listx", CAMLQuery: "<Query><Where><Eq><FieldRef Name='Entity'/><Value Type='Text'>ABC</Value></Eq></Where></Query>",  valuepairs: [["Content Type", "CT2"],["Keywords", "works"]]
  });

Coordinator
Jul 25, 2011 at 1:50 PM

Marijn:

I haven't tried it. I'd suggest trying to change the Content Type on one item with a simple call to UpdateListItems as a test. If the valuepairs approach doesn't work, then try using CAML directly instead. It'll be easier to debug any issues at the level. If you get errors, let me know hwat they might be.

M.

Jul 26, 2011 at 10:58 AM
Edited Jul 26, 2011 at 11:11 AM

Got it to work on SP2010, but not on SP2007. Will try further.

EDIT: works on 2007 too, the document I was trying it on was broken.

Coordinator
Jul 26, 2011 at 1:50 PM

Good to hear, Marijn. It would be great if you could post the code you ended up with to help others with similar goals.

Thanks,
M.

Jul 26, 2011 at 2:34 PM

Ofcouse, how silly of me.

My code:

$(document).ready(function()
{
 $("#btnChange").click(function(){

alert('start');
 $().SPServices.SPUpdateMultipleListItems({
  listName: "Shared Documents",
  CAMLQuery: "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>test</Value></Eq></Where></Query>",
  valuepairs: [["ContentType", "Report"]]
}); 
alert('end');
});
});

</script>

<input type="button" id="btnChange" value="Mod Content Type" />
Coordinator
Jul 26, 2011 at 9:23 PM

Marijn:

Thanks for posting you code. It looks like it was as simple as I thought it would be! I'm glad I wasn't way off base.

M.