Use a custom SPD action to extract an attachment from an InfoPath form and add it to a SharePoint document library
Learn how you can create a custom SharePoint Designer activity that can be used as an action in a workflow that runs on InfoPath forms to extract an attachment from an InfoPath form and upload it as a file to a SharePoint document library.
Once you’ve mastered the basics of InfoPath and understand how it hangs together, you can come up with many cool solutions that can increase productivity of non-technical employees in your organization.
One such a solution is for example if you’ve got InfoPath forms stored in a SharePoint form library and these InfoPath forms contain documents stored in a File Attachment control on the form.
You could create a custom SharePoint Designer (SPD) activity that can be used as an action in a SharePoint Designer workflow that can be run on InfoPath forms to extact InfoPath attachments and upload them to a separate SharePoint document library.
While I’ve already previously written about such a solution, that solution dealt with using a workflow developed in Visual Studio to extract and upload InfoPath form attachments to SharePoint and the SharePoint document library to which files are uploaded was hardcoded in the workflow code.
While you could add flexibility to a Visual Studio workflow to pass the name of the SharePoint document library to the workflow using initiation forms, creating Visual Studio workflows for SharePoint is a complex process in itself.
A custom SPD action not only provides ease of use for the SharePoint end-user, but also less development effort for you as a programmer.
You can combine the information presented in the following two articles to put an InfoPath file extract solution using a custom SPD action together:
- Building Custom Activities for Use in SharePoint Designer 2007
- Use a custom SharePoint workflow to extract a file attachment from an InfoPath form and upload it to a SharePoint document library (Note: You’ll have to modify the code in step 8 slightly and add it to the Execute method of the custom SPD activity)
If you want to see what this solution looks like in action, I’ve put together a short demo showing you how you can extract InfoPath form attachments using a custom SharePoint Designer action. The code has already been published in the second article I mentioned above, but if you’re still struggling to put it together, let me know, and I’ll post the code I used for the demo.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.