Submit list data to SharePoint using CAML - InfoPath Dev
in

InfoPath Dev

Having trouble finding a blog or post that answers your question? Check out our Custom Search Page

Submit list data to SharePoint using CAML

Last post 05-13-2010 07:38 AM by rZ3A8zj8neCW3K. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-13-2010 06:53 AM

    Submit list data to SharePoint using CAML

    Hello!

    I am having a small issue submitting data to a list using CAML.  I followed a guide here (along with other sites) to set up a data-receive connection using CAML.  I set up the CAML to have the exact fields that the corresponding SharePoint list has columns.  I then created a data-submit connection (UpdateListItems) to subject data to a SharePoint site, using that CAML recieve connection and a hidden field in my form that contains a GUID.  here is a screencap of the settings. (image)

     My GUID is formatted like this: {367C41F9-D404-4459-8509-B9702A091A54}

    Here is my CAML:

    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="1.1.0" />
    <Field Name="1.1.1" /> 
    <Field Name="1.1.2" />

      <Field Name="1.1.3" />
      <Field Name="1.1.4" />
      <Field Name="1.1.5" />
      <Field Name="3.0.0" />
      <Field Name="3.1.0" />
      <Field Name="3.2.0" />
      <Field Name="3.3.0" />
      <Field Name="3.4.0" />
      <Field Name="3.5.0" />
      <Field Name="3.6.0" />
      <Field Name="3.7.0" />
      <Field Name="3.8.0" />
      <Field Name="3.9.0" />
      </Method>
      </Batch>

    Here are the columns on my SharePoint Site (image)

    On submit, I "build the CAML" by doing this (I am using "TEST" as dummy data for now):

    XPathNavigator camlRows = DataSources["RECEIVE_CAML_ANSWERLIST"].CreateNavigator();
    while
    (rows.MoveNext())
    {
         submit_counter++;
         camlRows.SelectSingleNode(
    "/Batch/Method/Field[" + submit_counter + "]", NamespaceManager).SetValue("TEST");
    }

    Once it is built, I have double checked, printed the camlRows.outerXML to the console, and I get this:

    <Batch OnError="Continue">
        <Method ID="1" Cmd="New">
            <Field Name="1.1.0">TEST</Field>
            <Field Name="1.1.1">TEST</Field>
            <Field Name="1.1.2">TEST</Field>
            <Field Name="1.1.3">TEST</Field>
            <Field Name="1.1.4">TEST</Field>
            <Field Name="1.1.5">TEST</Field>
            <Field Name="3.0.0">TEST</Field>
            <Field Name="3.1.0">TEST</Field>
            <Field Name="3.2.0">TEST</Field>
            <Field Name="3.3.0">TEST</Field>
            <Field Name="3.4.0">TEST</Field>
            <Field Name="3.5.0">TEST</Field>
            <Field Name="3.6.0">TEST</Field>
            <Field Name="3.7.0">TEST</Field>
            <Field Name="3.8.0">TEST</Field>
            <Field Name="3.9.0">TEST</Field>
        </Method>
    </Batch>

    Finally, before I execute the data connection:

    e.CancelableArgs.Cancel = false;

    And then the last statement is:

    try
    {
        
    this.DataConnections["SUBMIT_ANSWERLIST"].Execute();
    }
    catch (System.Net.WebException webExc)
    {
         //This will print the exception to a field on the form I am using for error tracking
        
    this.err_appendOnScreenError(webExc.Message+"\n"+webExc.StackTrace + "");
    }

    It just doesn't submit... I'm not sure where to start?  I got this to work once before, but now I'm not getting any sort of error and it just does not submit.  It does not throw any exceptions or display any errors.

     Thanks for all your help so far!

    - rZ3A8zj8neCW3K
    Filed under:
  • 05-13-2010 07:38 AM In reply to

    Re: Submit list data to SharePoint using CAML

    Update:

    I GOT IT TO WORK!

    I did some more searching on here, if anyone stumbles on this in the future I fixed it by reformatting my CAML to this:

    <?xml version="1.0" encoding="UTF-8"?>
    <Batch OnError="Continue">
        <Method ID="1" Cmd="New">
            <Field Name='Title'></Field>
            <Field Name="_x0031__x002e_1_x002e_1">TEST</Field>
            <Field Name="_x0031__x002e_1_x002e_2">TEST</Field>
            <Field Name="_x0031__x002e_1_x002e_3">TEST</Field>
            <Field Name="_x0031__x002e_1_x002e_4">TEST</Field>
            <Field Name="_x0031__x002e_1_x002e_5">TEST</Field>
            <Field Name="_x0033__x002e_0_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_1_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_2_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_3_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_4_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_5_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_6_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_7_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_8_x002e_0">TEST</Field>
            <Field Name="_x0033__x002e_9_x002e_0">TEST</Field>
        </Method>
    </Batch>

    How did I get that?  Go into Settings > List Properties, mouse over a column, look at the URL:

    The very END of the URL will look like this

    ?List=%7B367C41F9%2DD404%2D4459%2D8509%2DB9702A091A54%7D&Field=%5Fx0033%5F%5Fx002e%5F0%5Fx002e%5F0

    Essentially:

    ?List=GUID&Field=ColumnID

    We know from the GUID that %5Fx0033%5F%5Fx002e%5F0%5Fx002e%5F0 is not acceptable, so I had to reformat it to remove all the HTML coding...

     

    - rZ3A8zj8neCW3K
Page 1 of 1 (2 items)
Copyright © 2003-2014 Qdabra Software. All rights reserved.
View our Terms of Use.