Create New Item in a Specified Folder

Feb 21, 2011 at 11:31 AM

The SPServices documentation for the Lists Web Service - UpdateListItems, provides a nice example of using SPServices to create a new Item into a List. I've copied this example below.

How can this be modified so that the Item is created in a particular Folder in the List; in this case the CreateNewItem function might take a third parameter to specify the name of the folder that the Item should be created in.

     function CreateNewItem(subject, message, folderName) {

Thank you for your help!

function CreateNewItem(subject, message) {
    $().SPServices({
        operation: "UpdateListItems",
        async: false,
        batchCmd: "New",
        listName: "Feedback",
        valuepairs: [["Title", subject], ["Message", message]],
        completefunc: function(xData, Status) {
            alert("completed");
        }
    });
}

Feb 21, 2011 at 7:05 PM

Hi,

SPServices provides an excellent wrapper around the web services. It's always a good practise to check out the web service itself at MSDN, the links are provided in the Documentation section of this site.
The documentation for UpdateListItems can be found here: http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems.aspx
At the bottom of the page is a nice example of how to create an item in a particular folder.

Regards, Anita

Feb 21, 2011 at 8:07 PM

Thank you for your reply, but I do not want to create a new Folder; I want to add a new Item in an existing Folder within a List. Additionally, in case it makes a difference, my need is to create a new Item in a particular Folder in a List; not a Library.

Thank You,

Joe

Coordinator
Feb 21, 2011 at 9:40 PM

Joe:

Keep scrolling down into the community content on that page. There's an example of what you want to do, as Anita pointed out.

M.

Feb 21, 2011 at 10:56 PM

I had scrolled all the way down to the bottom but I see it now. Thanks very much!