This project has moved and is read-only. For the latest updates, please go here.

Can I use SPUpdateMultipleListItems to move items into subfolder on same list?

Jan 30, 2012 at 8:54 PM
Edited Jan 30, 2012 at 9:06 PM

Great work on spServices! I love it and use it a lot on my sites.

Currently, I am trying to use SPUpdateMultipleListItems to move List Items into a sub-folder on the same list after they are created. The reason it needs to be after the item is created is because some of the list items are uploaded into a Dataasheet view from external sources, so I cannot use PreSaveAction for instance to facilitate this behavior. I am creating this in a MOSS site and would like to be able to click a button on a custom "Administrators Page" to mass move all items that match certain criteria into a newly created sub-folder on the list that has pre-defined custom folder level permissions. What I can't figure out is how to get the items to move to the sub-folder. I tried updating URLPath in valuepairs parameter, but that did not work. Any help will be greatly appreciated.

here is what I have:

		$(document).ready(function() {

				  operation: "UpdateListItems",
				  async: false,
				  listName: "Contact Cards",
				  updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +  
				           "<Method ID='1' Cmd='New'>" + 
				           "<Field Name='FSObjType'>1</Field>" + 
				           "<Field Name='BaseName'>NewSubFolder</Field>" + 
				           "</Method>" + 
				  completefunc: function(xData, Status){
This code above allows me to create a sub-folder. How do I mass move my items into the folder now?
This is what I was trying that did not work (below):
				  listName: "Contact Cards",
				  CAMLQuery: "<Query><Where><Eq><FieldRef Name='CompanyName'/><Value Type='Text'>MyTestCompany</Value></Eq></Where></Query>",
valuepairs: [["FileRef", "site/Lists/Listname/SubFolderName"]], debug: true });
Jan 31, 2012 at 6:56 PM


I don't think that you'll be able to use SPUpdateMultipleListItems for this. The valuepairs shortcut is only good for setting column values across a set of items.

I could have sworn I had an example of "moving" a list item from one folder to another, but I haven't been able to find it.


Feb 1, 2012 at 12:43 AM
Edited Feb 1, 2012 at 12:47 AM

I gotcha Marc. :)


Here's a sample batch command that will move items to a folder of your choice.  You'll need to expand upon it to accommodate your needs, but should be a good start to get you going.


var updateCAML = "<Batch OnError='Continue' PreCalc='TRUE'>" +
	"<Method ID='1' Cmd='Update'><Field Name='ID'>" + id + "</Field>";

	//Used the first solution from the comments. Didn't try the other solution...
	updateCAML += 	"<Field Name='FSObjType'>0</Field>" +
		"<Field Name='BaseName'>" + FOLDER_NAME + "/" + $("#mahCurrentFolder").val() + "</Field>";

	updateCAML += 	"<Field Name='SomeColumn01'>" + STSHtmlEncode( someValue01 )  + "</Field>" +
			"<Field Name='SomeColumn02'>" + STSHtmlEncode( someValue02 )  + "</Field>" +
			"<Field Name='SomeColumn03'>" + STSHtmlEncode( someValue03 ) + "</Field>" +
			"<Field Name='SomeColumn04'>" + STSHtmlEncode( someValue04 ) + "</Field>" +
			"<Field Name='NewTab'>" + tabToggle  + "</Field>" +
			"<Field Name='SomeColumn05'>" + STSHtmlEncode( someValue05 )  + "</Field>" +
		"</Method>" +


If I remember correctly, you don't need to have the: 


as part of the BaseName.  I'm like 99% sure of this, but haven't the need to test this code in a while.

Hope it helps!

Feb 1, 2012 at 2:26 PM

@sadjei - any luck on the solution? im trying to do the samething. Tried the solution above with no luck

Feb 3, 2012 at 5:49 AM

Not really Joe, but I took a different route for now. My code currently creates a sub-folder in a separate list based on selections made on current item. I execute this in the PreSaveAction function. Then I set permissions on the folder and manually move my bulk loaded items into the sub-folder through the Site Manager (_layouts/sitemanager.aspx). (not ideal, but a good enough solution for now.)

Eventually, I want all that to happen in the same function so the user wouldn't need to worry about it.

Thanks for the pointers though marc and iOnline.. I will explore further.