UpdateListItems + CAML + File Attachment - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

UpdateListItems + CAML + File Attachment

Last post 08-24-2010 03:01 PM by Hilary Stoupa. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 08-23-2010 07:08 AM

    UpdateListItems + CAML + File Attachment

    Hello!

     I am trying to include an attachment in some already working code that creates a new item in a SharePoint list.  I have read that you can do this by including the attachment as a field in your CAML document.  The field will hold an encoded string that represents the file.  I want to do this using the CAML document. 

     Here is an example of the type of CAML document I am using already:
     <?xml version="1.0" encoding="UTF-8" ?>
    <Batch OnError="Continue">
     <Method ID="1" Cmd="New">
      <Field Name="Title" />
     </Method>
    </Batch>

     Here is an example of how I would encode the XML infopath form file when I attach the file to the CAML (if possible, as an encoded string):
    http://www.bizsupportonline.net/blog/2009/01/submit-infopath-form-sharepoint-list-attachment/
    string formXml = MainDataSource.CreateNavigator().OuterXml;
    byte[] attachment = Sytem.Text.Encoding.UTF8.GetBytes(formXml);
    item.Attachments.Add("InfoPathForm.xml", attachment);

     Here is an example of what I mean, a typical SharePoint list that can have attachments on each item.
     SharePoint attachment

    I'm having trouble finding any sources that explain how to set up the CAML document properly.  I believe I will be able to encode the file and insert it into the CAML without issue, but I'm not sure what the CAML needs to look like so that SharePoint will accept the field as an attachment.

     Edit: I have seen this http://www.bizsupportonline.net/browserforms/how-to-use-sharepoint-object-model-submit-data-infopath-browser-form-sharepoint-list.htm 
     but for some reason I am unable to complete steps 5 and 6: 
    1. In the Project Explorer window in Microsoft Visual Studio Tools for Applications, right-click the node for the project name, and select Add Reference from the context menu.
    2. On the Add Reference dialog box, select Windows® SharePoint® Services from the list of components on the .NET tab, and click OK.
    - rZ3A8zj8neCW3K
  • 08-23-2010 12:37 PM In reply to

    Re: UpdateListItems + CAML + File Attachment

    looks like someone else has this same exact issue

    http://www.infopathdev.com/forums/p/10870/38710.aspx#38710

    - rZ3A8zj8neCW3K
  • 08-23-2010 11:41 PM In reply to

    Re: UpdateListItems + CAML + File Attachment

    I responded to the other post. Please read that and download the free qRules v2.3 trial and you'll have this working without code in 30 minutes. If you want to continue down the BizSupportOnline.net path, go for it, but we don't support that. Sorry, but we have to pay for this forum in some way and qRules is that way. It will save you money and help support the forum. You can get a discount off of the already cheap price of $199 by providing a testimonial.

    Patrick Halstead
    Project Manager at Qdabra
  • 08-24-2010 07:16 AM In reply to

    Re: UpdateListItems + CAML + File Attachment

    Will the qRules generate CAML files for me?  I'm looking on this page http://www.qdabra.com/en/products/qRules.aspx but it is not clear, I think if the page was revised to have more detailed information it might be more effective.

    - rZ3A8zj8neCW3K
  • 08-24-2010 03:01 PM In reply to

    Re: UpdateListItems + CAML + File Attachment

    No, qRules doesn't generate CAML files -- it actually handles the entire submit process. You simply add some data connections and provide a mapping and the tool does the rest.

    Hilary Stoupa

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