Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have an InfoPath 2010 form with a "Resume" attachment. When the form gets submitted to the SharePoint document library, I need to display the resume attachment as a document library's column. Every solution method that I am finding is based on InfoPath/SharePoint 2007, which is not working the same way with 2010. I know there should be a workflow to create in the SharePoint Designer, and can't figure out what it is. If anybody has this knowledge, please help.

share|improve this question
add comment

2 Answers

You will have to include custom code in the submit button of your InfoPath form and you will have to give the InfoPath form template Full Trust for the code to work in SharePoint.

// Retrieve the value of the attachment in the InfoPath form
XPathNavigator ipFormNav = MainDataSource.CreateNavigator();
XPathNavigator nodeNav = ipFormNav.SelectSingleNode("//my:document", NamespaceManager);
string attachmentValue = string.Empty;
if (nodeNav != null && !String.IsNullOrEmpty(nodeNav.Value))
{
    attachmentValue = nodeNav.Value;
    // Decode the InfoPath file attachment
    InfoPathAttachmentDecoder dec = new InfoPathAttachmentDecoder(attachmentValue);
    string fileName = dec.Filename;
    byte[] data = dec.DecodedAttachment;
    // Add the file to a document library 
    using (SPSite site = new SPSite("http://ServerName"))
    {
        using (SPWeb web = site.OpenWeb())
        {
            web.AllowUnsafeUpdates = true;
            SPFolder docLib = web.Folders["MyDocuments"];
            docLib.Files.Add(fileName, data);
            web.AllowUnsafeUpdates = false;
            web.Close();
        }
        site.Close();
    }
}

Please visit the Step 5 of this post to get the different options- http://www.bizsupportonline.net/blog/2010/04/top-10-questions-infopath-file-attachments/

or view this post directly- http://www.bizsupportonline.net/blog/2010/01/upload-document-sharepoint-infopath-form/

share|improve this answer
add comment

I would recommend to move all c# code out of the InfoPath form. Full Trust forms w/ code inside couldn't be deployed w/ CI or powershell to defferent SharePoint farms and that's pity.

In that case, it's better to move code to event receiver to sync attachments between InfoPath forms and 3rd part source like additional column/list/whatever it is.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.