How To: Save Images to SharePoint - Mel Balsamo Sign in | Join | Help in Mel Balsamo Tutorials (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads This Blog Home Syndication RSS Atom Comments RSS Recent Posts How To: Save Images to SharePoint How To: Capture Camera Images How To: Add Signature Capture to your Form Query Forms from within other Forms Create a Child Form from within a Parent Tags Active Directory activeX Address block aduserinfo Advanced Contact approval AttachToSharePointList browser forms buttons calculated value Camera Capture Image Capture Signature child code contact block Contact lookup contact selector CopyTable DAT data validation Database Enumeration DBXL DBXL v2.2 DBXL v2.3 DeleteAttachment Design Checker error Electronic Signature email email forms EnumDB expense report external users footer FormsViewer header hide show section How To HREF Image image picker ImagePicker InfoPath InfoPath 2007 IPFS leave request link list lists Mobile parent PI policy public and private forms Qdabra Qdabra Email Builder Tool Qdabra Vertical Tabs XTP QdModifyPI Tool qESxtp qRules query forms QueryDB RefreshSharePointListItems repeating repeating data repeating group repeating section repeating table Save images to SharePoint SaveToSharePoint secondary data source send emails separate libraries SetValue SharePoint sharepoint list Signature smart links split forms submit forms SubmitToSharePointList tabbing template part Vertical tabs Web Service workflow XTP Archives September 2017 (3) March 2017 (3) January 2013 (1) July 2012 (1) October 2011 (1) July 2011 (1) June 2011 (2) March 2011 (1) December 2010 (4) November 2010 (1) May 2010 (3) February 2010 (1) January 2010 (1) December 2009 (3) September 2009 (2) July 2009 (2) June 2009 (1) May 2009 (3) March 2009 (3) February 2009 (1) January 2009 (2) December 2008 (1) Mel Balsamo How To: Save Images to SharePoint Prerequisites: You should already have FormsViewer installed and understand how to upload and open forms. You should already have an XSN form template that includes a Picture Control or File Attachment Control. If you are not familiar with Picture Controls, please see our How To: Capture Camera Images Your form template should already be injected with qRules. Steps: In SharePoint locate or create document library that you would like to use for storing images or files from your form. Open your form in InfoPath Design mode. In the Fields pane, locate the base64Binary field from which you would like to save out files to SharePoint. Add a qRulesLink attribute to the field: Right-click the field Click Add… Enter the name qRulesLink (use this exact spelling and capitalization) Click OK Repeat step 4, but with the name qRulesFilename instead of qRulesLink. Note: Your data source may or may not be repeating depending on your needs. In this example, we are allowing users to attach more than one photo in the form so we’re showing a repeating group. Make sure that the Rules taskpane is open. Add a formatting rule to hide the control when the file has been saved out: Locate the Picture or File Attachment Control that is bound to your field and click it. In the Rules pane, click New à Formatting Give the rule the name “Hide when file saved” Under Condition: click the blue None text. Using the condition builder: Use the left dropdown to select the qRulesLink Use the middle dropdown to select is not blank. Click OK Check the Hide this control box. Add a section control and hyperlink for the link to the file: Use your mouse to drag your picture or attachment field from the Fields pane to a location right next to your Picture or Attachment control. When prompted for a control type, click Section. Click to place your cursor inside the newly created Section Control. Select the Insert tab and click Hyperlink. When prompted for the hyperlink’s properties: For Link to, select the qRulesLink For Display, select the qRulesFilename Click OK. Click and drag the right edge of the Hyperlink so it fills most of its container. If you wish to display a thumbnail of the linked image aside from the link itself, drag the qRulesLink field inside the section as a Picture control – right-click on the field on the Fields taskpane, select More and then select Picture Set the control as read-only and also adjust the qRulesLink photo control with a fixed width or height of your choice so that it appears like a thumbnail on your form. Add a formatting rule to hide the section control when the file has not been saved out: Repeat the sub-steps from step 7, with these differences: Instead of clicking the Picture or File attachment, click the Section control you created in step 8-b. Instead of selecting is not blank in the condition builder, select is blank. Add a button to your view and give it meaningful text like “Upload Photo” Add a rule to the button to save out the image: Click the button. In the Rules taskpane, click New à Action Click Add à Set a field’s value In the Set a field’s value dialog: For the Field, select the Command field in the QdabraRules secondary data source. For the Value, paste the following command text, and replace the highlighted parts as indicated: SaveToSharePoint /url=[full URL to SharePoint library, up to the library’s name] /xpath=[full XPath to your picture or file field] Click OK Save the template and upload it to FormsViewer. Open the form in FormsViewer, add a file to your Picture or File Attachment Control. Click the button to upload the file. If it worked correctly, you should see the Picture or File Attachment Control disappear and it should be replaced with a thumbnail and a link to the saved out file. Clicking the link should take you to the uploaded image into the SharePoint library, showing full resolution. Notes: If you are saving out pictures, replace the hyperlink with a Picture control that is bound to the qRulesLink This control should display the picture by loading it from its location in the library. Try the above steps on a picture or attachment field in a repeating group/repeating section. The SaveToSharePoint command should work without any additional changes. Add the rule from your Save Files button to your form’s Submit button. Place this rule before the rule that actually submits the form. This should cause files to save out before your form is saved, reducing the size of your documents and the speed of your submits. Published Sep 05 2017, 06:10 AM by Mel Clemente Filed under: SharePoint, InfoPath, FormsViewer, Mobile, Image, Capture Image, Camera, Save images to SharePoint, SaveToSharePoint Comments No Comments Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Note: Your data source may or may not be repeating depending on your needs. In this example, we are allowing users to attach more than one photo in the form so we’re showing a repeating group.