Infopath multiple attachments to SP library and with few fields from Infopath Form - InfoPath Dev
in

InfoPath Dev

Infopath multiple attachments to SP library and with few fields from Infopath Form

Last post 02-11-2013 07:48 AM by EMSCA. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-08-2013 12:34 PM

    • EMSCA
    • Not Ranked
    • Joined on 02-08-2013
    • Posts 12

    Infopath multiple attachments to SP library and with few fields from Infopath Form

    Hi,

     

    Ive created a process to upload multiple attachments using InfoPath repeating table to SP document library, Written the code in Btn click event. Please check the code below, it's working fine, now i'd like to save data rom few fields of InfoPath from, fields like Form Name, Form ID..I tried few options to add fields data to SP library while attachments upload but no luck

     

    Could you please suggest how i can code to submit items to Library

     

    This button i'm using to load attachments to Doc Library,

     

    public void CTRL62_5_Clicked(object sender, ClickedEventArgs e)

    {

    // Write your code here.

    XPathNavigator ipFormNav = MainDataSource.CreateNavigator();

    XPathNodeIterator nodes = MainDataSource.CreateNavigator().Select("/my:Project/my:AddAttachmnet", this.NamespaceManager);

    // XPathNavigator xnProjectName = MainDataSource.CreateNavigator().SelectSingleNode("/my:Project/my:ProjectName", this.NamespaceManager);

    string attachmentValue = string.Empty;

    string ProjectName = string.Empty;

    foreach (XPathNavigator node in nodes)

    if (node != null && !String.IsNullOrEmpty(node.Value)){

    attachmentValue = node.Value;

    InfoPathAttachmentDecoder dec = new InfoPathAttachmentDecoder(attachmentValue);

    string fileName = dec.Filename + System.DateTime.Now.ToString("yyyyMMddHHmmssfff");

    byte[] data = dec.DecodedAttachment;

    // Add the file to a document library

    using (SPSite site = new SPSite("web site addess"))

    using (SPWeb web = site.OpenWeb()){

    web.AllowUnsafeUpdates = true;

    SPFolder docLib = web.Folders["Doc library"];

    docLib.Files.Add(fileName, data);

    //docLib.Item["ProjectName"] = xnProjectName;

    web.AllowUnsafeUpdates = false;

    web.Close();

    }

    site.Close();

    }

    }// If node is not null

    }/ foreach nodes

     



     

  • 02-09-2013 05:13 PM In reply to

    Re: Infopath multiple attachments to SP library and with few fields from Infopath Form

    Hi again,

    Our qRules common library plugin supports this. We provide qRules to help save time and the trial is free. We use the sales to pay for our time answering posts so we don't generally answer code posts if qRules commands support the scenario. Sorry, for the long-winded answer. qRules supports saving attachments to document libraries and changing their names, etc.

    What's the benefit to you? You can use the same technique in multiple form templates without writing code which means lower cost long term maintenance for you and your company.  We do provide hands on support for qRules and we have people here that speak lots of languages.

    Sorry for the pitch but we have to pay for the forum somehow. 

    Thanks for your understanding. Let us know if you are open to using qRules.

    :)

    Patrick Halstead
    Project Manager at Qdabra
  • 02-09-2013 05:15 PM In reply to

    Re: Infopath multiple attachments to SP library and with few fields from Infopath Form

    There are some CAML techniques for writing to doc library columns.
    Patrick Halstead
    Project Manager at Qdabra
  • 02-11-2013 07:48 AM In reply to

    • EMSCA
    • Not Ranked
    • Joined on 02-08-2013
    • Posts 12

    Re: Infopath multiple attachments to SP library and with few fields from Infopath Form

    I completely understand J . Actually I’m working for one of the Dept on intranet and there is Global IT team separately. Will check with them regards qrules Thank you so much!! J

     

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