what I'd like to do is to create multiple data records (of one type) in one call to the server.

The solution needs to work in SharePoint 2007 and the data is stored in an XML Data Source, i.e. an XML file referred to in the respective section of the "Data Source Library" view in SharePoint Designer.

The problematic part is: 'create multiple'. Creating a single record is no problem.

What I tried (without success) so far is:

A) do what you do to create a single record multiple times, i.e.: - create one or more ASP controls, do a databind of a change to different attributes of the data record (using the proper xpath) and end it with [new], do a commit, e.g.

<asp:CheckBox runat="server" id="stageActivation{$Pos}" text=" " checked="FALSE" __designer:bind="{ddwrt:DataBind('i',concat('stageActivation',$Pos),'Checked','CheckedChanged','',concat(string($xPathWithoutLastNode), '/Stage[new]'),'@activated')}"/>
later based on a user's button click:
javascript: {ddwrt:GenFireServerEvent('__commit')}

Problem here: If I repeat the first part (with different id, of course) a couple of times, only the last one results in a created data record at commit time. I assume that has something to do with the timing an actual server side id is created to fill the [new] part.

B) use CSOM

Problem here: Doesn't work because I have to live with SharePoint 2007, where this does not exist. Upgrading is unfortunately not an option at this point in time and I can't wait for it.

C) use UpdateListItems of the Lists Web Service (/_vti_bin/Lists.asmx)

Problem here: If the data source on the server would be a SharePoint List, it's quite easy (tried this successfully), but I need to write to an XML Data Source. It might be possible, but I didn't find any example how this can be done if it's possible. What I'm unsure about is: - what's the listName in this case? - do I specify the XPath in the field name or somewhere else? What I tried (doesn't work and just responds with 'Internal Server Error') is:

function createNewItem(site, listName, batch)
    var soapEnv =
        "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
        <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \
            xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \
            xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> \
          <soap:Body> \
            <UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"> \
              <listName>" + listName + "</listName> \
              <updates> \
                " + batch + " \
              </updates> \
            </UpdateListItems> \
          </soap:Body> \

        url: "http://" + site + "/_vti_bin/lists.asmx",
        beforeSend: function(xhr) {
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        error: processError,
        success: processSuccess,
        complete: processResult,
        contentType: "text/xml; charset=utf-8"
function createFiveStages(site, listName, parentNode)
    var batchHeader =
        "<Batch OnError=\"Continue\">";
    var batchFooter =

    var batchItems = "";
    for(i = 0; i < 5; i++)
        batchItems +=
            "<Method ID=\"" + (i + 1) + "\" Cmd=\"New\"> \
                <Field Name=\"" + parentNode + "/Stage[" + (i + 1) + "]/@index\">" + (i + 1) + "</Field> \
                <Field Name=\"" + parentNode + "/Stage[" + (i + 1) + "]/@activated\">False</Field> \

    var batch = batchHeader + batchItems + batchFooter;
    createNewItem(site, listName, batch);

D) do multiple round trips between server and browser using server variables and just create one item at a time

Problem: I want to avoid this, because it's unnecessary network traffic and has a big bad performance impact.

Any ideas? Can I get A or C to work, or are there other possibilities in SP2007?

Thanks in advance.

  • Now the code is showing correct, but since you have replaced all the ">" and "<" it is a bit hard to comprehend :) – Robert Lindgren Aug 2 '13 at 9:15
  • Thanks, Robert. " since you have replaced ...": absolutely. If you tell me how to correct it and post it again so that it shows correctly, I'll gladly do it. – PeterB Aug 2 '13 at 14:13
  • Now that the code is marked as code you can just go ahead and edit the post and just type the normal < > instead of their encoding :) – Robert Lindgren Aug 2 '13 at 14:58
  • Thanks. I just did it. Unfortunately two sections don't show up properly now, again. It seems some of the content is breaking the code section tagging (which is invisible in the edit window for me). – PeterB Aug 2 '13 at 15:30
  • 1
    code formatting finally corrected. Problem is still open. – PeterB Aug 13 '13 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.