Using CAML to update a sharepoint list... oh, my, god... - InfoPath Dev
in

InfoPath Dev

Using CAML to update a sharepoint list... oh, my, god...

Last post 08-05-2016 11:13 AM by EliLawson. 30 replies.
Page 1 of 3 (31 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 05-26-2011 06:25 AM

    Using CAML to update a sharepoint list... oh, my, god...

    Hi.

    I'm about to jump out the window. I've found many, many posts and even an online walk-through on how to do this: take data from my infopath form and update it back into a sharepoint list.

    I've boiled it down to be as simple as possible - no repeating stuff to put back... just 3 data pieces:
    1) An integer that's unique in the list that I use as the "ID" so Sharepoint knows which record to update
    2) One text string to submit into a particular column
    3) Another text string to submit into a particular column

    I have followed the steps located in this post, but it seems to be leaving something out because it doesn't tell me how to ensure Infopath is mapping the data in the controls to the CAML fields.

    http://blog-sharepoint.blogspot.com/2009/07/summary-how-to-programmatically-update.html#process-6

    So... I've setup a rule to set the field value of ID in /batch in my CAML connection upon submission, and can see that it's doing that...  but how do I map the text values for my 2 text string fields? They don't show in the CAML data connection list... all I see there is "Name".
     

    <?xml version="1.0" encoding="UTF-8"?>
     <Batch>
      <Method ID="1" Cmd="Update">
       <Field Name="ID"></Field>
       <Field Name="Recommendation_x0020__x0028_and_">TEST</Field>
       <Field Name="New_x0020__x0020_Weekly_x0020_Vo">TEST</Field>
      </Method>
     </Batch>

     I feel like I'm so very close... I just can't close the gap. I also have no code attached to my form (the blog post i just linked makes no mention of needing any)

     Can someone set me straight here?

     

    If it helps - Im using Infopath 2007, Sharepoint 2007, NOT a browser enabled form...

    Filed under:
  • 05-26-2011 06:34 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    As info, because I know it's coming... ;)

    qDabra is not really an option at this point due to the extensive steps i'll need to go through to get it installed on our intranet. (Sharepoint owner approval, then agreement from our Group's 7 different biz units because in the past people have installed random plugins like this that conflicted with others)

  • 05-26-2011 08:02 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Hey -- don't jump. :)

    It is a little challenging to set those field nodes to your text box values, because your target for your rule needs to have filter on it, i.e. Field[@Name="Recommendation etc"]

    And sure, qRules would make this easier, but you can still do this. I have a blog post here that explains how to manually modify your form's manifest.xsf to filter your rule target.

    Hilary Stoupa

  • 05-27-2011 02:17 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    I kinda get it - but the situation is a bit different. In the blog post, you explain how to update X when Y = Z.

    I need to update X... where X = Z ??

    If I set a rule to update @Name, where Field[@Name="Recommendation etc"] ...   it seems like I'd be replacing "Recommendation..." (i.e. the SP column name) with my new comment value, which isn't logical to me.

    Does that make sense? :(

  • 05-27-2011 02:32 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    I think I get it now, you said to update FIELD where NAME = Z...  trying that and seeing if I get any traction :)

  • 05-27-2011 02:48 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Well I tried but its still not updating the sharepoint record (though it says form was submitted).

    I checked the filter rules and it did underline what I entered,,,  it looks like this now in the rule in the target field:

    Field[@Name = Recommendation_x0020__x0028_and_]

    I dont have a way to check what that value is though, so I dont really know how to troubleshoot where this is going wrong :(

  • 05-27-2011 02:52 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Ok... stumped :(

     I added a field/name table to track what data is being put into the CAML template. My CAML looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
     <Batch OnError="Continue">
      <Method ID="1" Cmd="Update">
       <Field Name="Commitment_x0020_Id">5372</Field>
       <Field Name="Recommendation_x0020__x0028_and_">TEST</Field>
       <Field Name="New_x0020__x0020_Weekly_x0020_Vo">TEST</Field>
      </Method>
     </Batch>

    I have the test values in there just to see if it will update.  a) it doesnt update the record with ID 5372.... and b) my rules in my form are not changing the values of the CAML fields :(

    Here are the rules from my manifest:

       <xsf:rule caption="Set ID to update in Sharepoint" isEnabled="yes">
        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;caml&quot;)/Batch/Method/Field[../Batch/Method/Field/@Name = 'Commitment_x0020_Id']" expression="my:Commitment_ID"></xsf:assignmentAction>
       </xsf:rule>
       <xsf:rule caption="Set Feedback Value" isEnabled="yes">
        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;caml&quot;)/Batch/Method/Field[../Batch/Method/Field/@Name = 'Recommendation_x0020__x0028_and_']" expression="my:Feedback"></xsf:assignmentAction>
       </xsf:rule>
       <xsf:rule caption="Set Text Value" isEnabled="yes">
        <xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;caml&quot;)/Batch/Method/Field[../Batch/Method/Field/@Name = 'New_x0020_Weekly_x0020_Volume_x0']" expression="my:Comment"></xsf:assignmentAction>
       </xsf:rule>

  • 05-27-2011 06:39 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Ahhhh! I'm having a moment of brilliance!

    I'm trashing my Commitment_ID column and instead using the sharepoint ID column now...  now if I put the right ID in my CAML, it UPDATES! HURRAY!!!!!!

     But....   my form itself still isnt pushing the data into the CAML template - woe is me!! Can someone check out my manifest up above and see if it's something in the rules? It must be!

     i'm so close, I can taste it!!!!!!!

  • 05-27-2011 07:57 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Hey there -- you are correct, in order to update you need to have the SharePoint List Id. Good job figuring that out.

    Your XPath to your target field looks funny to me. I'd try this:

    xdXDocument:GetDOM(&quot;caml&quot;)/Batch/Method/Field[@Name = 'Commitment_x0020_Id']
    Hilary Stoupa

  • 05-27-2011 08:04 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    oh my god it works!!!!!!!!!!

     

    THANK YOU HILARY!!!!!!!!!!!!!!!!!!! !!!!!

     

    !

  • 05-27-2011 08:25 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Don't you love that feeling? Have a great day!

    Hilary Stoupa

  • 12-17-2012 10:33 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    I have done the same steps. What i have done is i get the column named AutoID from list and grab the AutoID and use it as a filename in the form library when that infopath form is submitted to the library. Then i add 1 to the AutoID and update the list items from the infopath form. Everything is working fine but only when i do preview of the form. When i publish it to the library, it does not update the AutoID column of the list. Is there anything i am missing?

    I just found out that if i open the form in browser it does not work but if i open it in the client's application it works. Does it needs to be set up like that way?

     Thank you for your help!!

  • 12-17-2013 06:21 AM In reply to

    • szala
    • Not Ranked
    • Joined on 11-25-2013
    • Posts 1

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Hi Hilary, runelynx, I just wanted to say thank you. For me the above mentioned soultion worked pretty fine. I am a beginner I hade to read many times your solution but finally worked perfectly. Thanks!!!
  • 04-21-2015 02:46 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

     

    I have created and populated a list.  All the column headings are simple words, no spaces or special characters.

    I have created a secondary data source to the list and dragged it on to the form to make a repeating table which displays OK.  I have included ID but not the other SharePoint standard columns (created, modified, etc).

    My first column is called, "Nominal", on the list and on the form but SharePoint calls it, "Title".  Is that what I should call it in the .xml?  I have tried both without success.

    I have found the GUID for the list, added it to the form, created an .xml file, created a secondary data source from the .xml file.

    I think the XML data source is working OK.  If I drag it on to the form it displays as a two column repeating table.  "Name", is the list column headings and, "Field", is blank.

    I have created the web service submit referring to the GUID and the XML data connection as described in the Blog.

    What do I do next?

    The conversation between RuneLynx and Hilary all seems to be about setting filters on rules.  Because I am in InfoPath 2010 I think the filters are relatively easy.

    What I can't see is any mention of what the rules do.  I assume they are action rules that update fields?  Is that the empty, "Field", on the XML data connection?  Do I just update those and submit using the web service submit?  So when a row is changed it is copied to the empty XML fields and submitted and then if another row is amended the process is repeated?

     

    By the by, I am using InfoPath 2010 on SharePoint 2013 in the cloud.  We cannot sandbox or administer or in anyway publish with code!  Would prefer a solution that works in a browser but we can use filler for this form as it will only be used by a couple of administrators.

  • 04-21-2015 04:31 AM In reply to

    Re: Using CAML to update a sharepoint list... oh, my, god...

    Answered my own question :-)

    Set up an action rule on each field of the repeating table from the secondary source that might be changed..

    Each rule has as many clauses as there are columns to update.  Each clause sets "Field" on the CAML data source to equal the appropriate field in the repeating table.

    But then filtering doesn't work even in 2010, you still have to go in and set the filter condition on each action as per Hilary's advice.

    And a final clause to submit using the web service submit and I can update the list to my hearts content.

    All I need to do now is right in the rules that stops the user changing values to inappropriate values and automatically sets some of the values for them behind the scenes.

    You guys on InfoPathDev are the tops!  Thank you so much

Page 1 of 3 (31 items) 1 2 3 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.