Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can I add a new list item in side an existing folder in the list using the OOB SharePoint Lists.asmx web service?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I finally found out the solution:

By using the following batch element you can create an item inside a folder in a list or library

<Batch OnError="Continue" RootFolder="http://moss/Lists/CustomersList/FirstFolder">
  <Method ID="1" Cmd="New">
    <Field Name="ID">New</Field>
    <Field Name="CustomerName">Robert Hay</Field>
    <Field Name="CustomerAddress">Redmond</Field>
    <Field Name="Title">customer2</Field>
  </Method>
</Batch>

The important attribute here is the RootFolder. You need to provide the URL of the folder where you wish to create the item. So right now the RootFolder value is http://moss/Lists/CustomersList/FirstFolder which means thus batch element will create an item inside a prexisting folder FirstFolder inside a list CustomerList.

Further if there is another subfolder say SecondFolder inside the FirstFolder folder where you wish to create the item, then the RootFolder should have this value http://moss/Lists/CustomersList/FirstFolder/SecondFolder

For how to proceed using this batch element this MSDN article proves to be the good source http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems(office.12).aspx

share|improve this answer
    
Looks like the same link I included above. Sorry I didn't explicitly say it, but my purpose of including the first link was to give you background information on the Lists.asmx web service in case you didn't have any. My intention was for you to combine that with the information in the second link to derive at your answer. Glad you figured it out! –  Rob Wilson Sep 19 '10 at 16:32

A great walk-thru on using the Lists.asmx web service is available here: http://www.codeproject.com/KB/sharepoint/SharePointListWebService.aspx

The MSDN library has some info on how to work with lists with folders: http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems(office.12).aspx

share|improve this answer
    
Rob, the link above coveres how we can create, update, delete list items. But none of it really shows how we can create a list item inside a folder in the list. –  Vivek Sep 19 '10 at 4:51
    
I added a comment below. –  Rob Wilson Sep 19 '10 at 16:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.