SharePoint/Infopath 2010 Multiple attachments to SP library
January 28th, 2013 4:47pm

Hi E MS,

I believe this TechNet contains the info you need to achieve your goal:

http://support.microsoft.com/kb/2517906

For your attachment limitations question, I'll refer you to Clayton Cobb's answer at http://social.msdn.microsoft.com/Forums/fi-FI/sharepointinfopath/thread/72f14b1b-bc01-4540-acd4-7f4f5eb44952

"I highly recommend not having tons of attachments?  Why does the business process include such a thing?  Can the business process not be improved?  Attachments should be a rarity, not an institution.  If there are that many documents being used, then they should really be put into actual document libraries, not be stored inside the XML of InfoPath forms as Base64 binaries.

The technical answer to your question is that there is not only a file size limit to the entire InfoPath form that comes from your web app settings, but there is also a session size limit that is much smaller and is controlled within the IPFS settings of Central Admin.  50 attachments in one form

Free Windows Admin Tool Kit Click here and download it now
January 28th, 2013 6:03pm

Thank you so much for your response Keith. I'll follow this code process and update you back. Second link is not working for me(Clayton Cobb's answer)

Thanks Again!!


  • Edited by E MS Monday, January 28, 2013 7:04 PM
January 28th, 2013 6:59pm

 

Hi Keith,

In the first link, I see  as encode and decode code of attachment is available, no specific directions for saving from InfoPath repeating to SP library, what kind of alterations have to apply to that code, please provide some light


  • Edited by E MS Monday, January 28, 2013 7:09 PM
Free Windows Admin Tool Kit Click here and download it now
January 28th, 2013 7:07pm

Hi,

See pint no 5 in below article:

http://www.bizsupportonline.net/blog/2010/04/top-10-questions-infopath-file-attachments/

You can also see my reply in below thread:

http://social.msdn.microsoft.com/forums/en-US/sharepointcustomizationlegacy/thread/653449d2-7dd2-4a94-862e-32e393ef4cbc

Hope it could help

January 29th, 2013 10:49am

Thanks for  your help Hemendra!!  I tried First link and it working fine for one attachment to SP library, I'm looking for multiple attachments to SP library, I added Attachement node to repeating table of infopath form, so on the form i can add more attachments, but using frist link code only first attachment getting saved at SP library.

Seems some code modifications needed. Please provide some help on this. Thank you!!



  • Edited by E MS Tuesday, January 29, 2013 10:12 PM
Free Windows Admin Tool Kit Click here and download it now
January 29th, 2013 10:11pm

Hi,

You have to loop through repeating table to get all rows and their values. Use (row.MoveNext()) as shown in below link:

http://www.bizsupportonline.net/infopath2007/loop-through-items-repeating-table.htm

You need to use whole code inside the MoveNext so you can read attachment one by one and save into library.

Let us know if still have any doubt

January 30th, 2013 4:18am

Thanks for your help!  I added Foreach loop to reapting attachment nodes using c# in code behind and It did magic for me, Uploading all the attachments to SP library.

Thank You so much for your help. Please check the code in Btn click

    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);
              string attachmentValue = 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("Your site url"))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        SPFolder docLib = web.Folders["your document library name"];
                        docLib.Files.Add(fileName, data);
                        web.AllowUnsafeUpdates = false;
                        web.Close();
                    }
                    site.Close();
                }
            }// If node is not null


        }// foreach nodes


        }

  • Edited by E MS Wednesday, January 30, 2013 4:54 PM
Free Windows Admin Tool Kit Click here and download it now
January 30th, 2013 4:51pm

Hi Hemendra,

While uploading document, i like to save few fields data of Infopath form like to SP library, so like attachmemnts and few fields Data like form name, type which is enter by user, will save to SP library. Please suggest me how to achive this with code modifications

Thank you so much for your help!!


  • Edited by E MS Thursday, January 31, 2013 3:09 AM
January 31st, 2013 3:08am

Hi,

You can form fields data in library while publish the form. When you publish the form in library then you can add form field in wizard to save values of those fields in library. See below screen:

Free Windows Admin Tool Kit Click here and download it now
January 31st, 2013 6:26am

Actually I like to publising and add data to the  fields using c#..I'm using two doc libraries here, one for attachment upload and second one is for all fields data storage.

As i have button for upload attachments to SP library. That button is uploding documents to SP library with that attahmet , i  like to send data to fields as well, data like Form name and ID so those two fields/meta data will reside with attachment, for reference.

So is there any possiblity to add code and send data while uploading documents to SP library, please suggest on this

  • Edited by E MS Friday, February 01, 2013 5:33 PM
February 1st, 2013 5:31pm

Hi EMS,

I was able to extract multiple files attachments from Infopath 2013 browser based forms moving forward. How do I extract multiple files attachments from already submitted forms? 

Any idea on how to do this?
Snehal 
Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 3:16pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics