Adding List items to a particular folder updatelistitems webservice

Jun 4, 2012 at 10:15 AM
Edited Jun 4, 2012 at 10:15 AM


Hi Geeks,

I have a requirement to add list items to specific folders inside Sharepoint list. Please help.

The folders are pre created and kept inside the sharepoint list. Now need to add the items into those folders. While i am trying its going directly  to the list outside the folders. Please help. I have tried query options not working .

var queryOptions_YOC = "<QueryOptions><Folder>YOC_D/" + folderName_YOC + "</Folder></QueryOptions>";

Have seen many articles how to retrive the items from a specific folder, but no where found how to add items. Please help

Thanks

Janesh

 

 

Jun 4, 2012 at 4:53 PM

Use the "UpdateListItems" method, batchCmd = "New", and in the value pairs argument you specify the "BaseName" field as folder/title and the "Title" field as just the title: For instance, if I have a folder called Widgets and I want to add a "Thingy" inside that folder, it would be....

  $().SPServices({
      operation: "UpdateListItems",
      async: false,
      batchCmd: "New",
      listName: "My List Name",
      valuepairs: [["BaseName", "Widgets/Thingy"], ["Title", "Thingy"],
      completefunc: function(xData, Status){
        //Do whatever here
      }
  });
Jun 13, 2012 at 4:14 AM

Works perfect!. Thanks a lot :)

Jun 21, 2012 at 12:18 AM

I'm running into a problem where I receive Error 0x80040e2f when I try and include multiple subfolders in the BaseName pair.

For instance if I wanted to add a list item "Thingy" to "Widgets/SubWidgets" (where SubWidgets is a folder inside the Widgets folder) I would think that "Widgets/SubWidgets/Thingy" would be the correct baseName value.

Am I doing something wrong that I just don't see?

Jun 21, 2012 at 3:56 AM
Edited Jun 21, 2012 at 3:58 AM

Hi dryles,

What i experienced is the same, then  in the basename i have used unique string(CurrentDate or something)

  $().SPServices({
      operation: "UpdateListItems",
      async: false,
      batchCmd: "New",
      listName: "My List Name",
      valuepairs: [["BaseName", "Widgets/<unique string>"], ["Title", "Thingy"],
      completefunc: function(xData, Status){
        //Do whatever here
      }
  });

This worked, Try this!

Jun 21, 2012 at 4:42 PM
Using the date as part of the basename worked perfectly.

Thanks!