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.

ADVERTISEMENTS

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:

  1. Building Custom Activities for Use in SharePoint Designer 2007
  2. 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.

 
 Subscribe via RSS or Email

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.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related Posts

ADVERTISEMENTS

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services