This seems to be really a hot topic based on the people trying to tackle this problem in many ways. In my 3 part article series, I would take a stab at this inherent problem with InfoPath forms (be it browser based or used via rich client).
So, First,Lets understand the problem. InfoPath with service pack 2 in 2003 onwards has added support for a new control called File Attachment control Now this control allows users to quickly attach file relating to the form. When a user saves the form, these files gets stored inside InfoPath xml data file in a base 64 encoded format. Every time when a user opens the form, InfoPath decodes the string and shows the correct file to the users. All is good thus far. But what really happens, is that the users started uploading those gigantic 2-3 MB files which inherently makes the form slower for other users who are not interested in attachment files. Problem!!! Right.
User will come back and demand that they would like like to be able to attach and retrieve files from the InfoPath but would like to speed the retrieval process. Hmmm! There are several ways to tackle this problem.
- Create a SharePoint Designer Workflow and use the custom workflow that Bart has written (LINK) This works nice, but only processes 1 file attachments. What if you have file attachment control inside a repeating table? hmmm.
- Second approach is to use Custom workflow and work with code. In this approach, the moment user saves the form to SharePoint library, a workflow kicks off which removes the encoded string of attachment and saves it to a SharePoint document library.
- This approach (and this is the one that I like) , is to create a custom ItemEventReciever and work with the code to remove those attachments, save those to SharePoint Document Library, Replace the file attachment control with .url file which has a direct link to SharePoint library and finally to update few meta-data inside document based on data collected in InfoPath form. Cool?
I will walk through step by step on the approach # 3 on how to accomplish this task in 3 step process. My next article, I will discuss on the removal of file attachment. In the meanwhile if you can go ahead and set things up for the upcoming series that will be great.
a) Create a new document library (Lets call it FileAttachments)
b) Create 2 custom column(DocumentType, UploadedBy) to the list.
That’s it, Please wait for my next article where in I will walk through step by step on creating an ItemEventReceiver to accomplish this.