Introduction

The File inline functions allow the retrieval of file information, including content, from various sources. This Knowledge Base article describes how to use these functions.

Implementation Details

In the Function Browser, the Files node has been added that includes the following functions:

Image

Get File From Content - Enables a user to get a file from data fields, expressions, base64-encoded data and other items containing the file’s content, and allows you to specify a filename.

Get File From Location - Enables a user to get a file from a file location which must be accessible at runtime, and allows you to specify a filename.

Get File From SharePoint Item Reference - Enables the user to get a file from a SharePoint 2010 Item Reference containing one or more documents.

Get File From SharePoint 2010 - Enables the user to get a file from a SharePoint 2010 document library.

Get File From InfoPath Attachments - Enables the user to get all documents contained in an InfoPath 2010 attachment field node.

Note: The return type for all FILE Inline Functions is STRING, because of the fact that the functions resolve to an XML structure containing the file name and the file contents.

For more details on the individual File Inline Functions, see the following topic and related sub topics in the help documentation:

http://help.k2.com/helppages/k2blackpearlUserGuide4.6.3/webframe.html?files_inline_function.html 

Example Scenario

We are using a scenario where a Word document is converted to a PDF document in a SharePoint 2010 Library and we want to add the PDF document as an attachment to an E-mail. We will use the Get File from SharePoint function to achieve this.

Follow the steps below to set up the scenario as described above. 

  1. Create two SharePoint Document Libraries where (1) a file can be uploaded and (2) a PDF document can be saved.
  2. Create a SharePoint Workflow Integration process on the first SharePoint Library that converts the file that is uploaded to the first library to a PDF document and saves it to the second SharePoint Library.
  3. Create a K2 Studio or a K2 Designer for Visual Studio SharePoint Workflow Integration process on the second SharePoint Library that starts when an item is created and sends a mail.
  4. Now edit the E-mail Event and go to the E-mail Settings step of the wizard.
  5. Click on the ellipsis next to Attachments at the bottom of the screen:
    Image
  6. Open the Files node, select the Get File from SharePoint function and click Add.
  7. The Configure Function screen opens. Provide the SharePoint site, Library Name and Document Name of the SharePoint Library where the PDF document is saved. Finish the wizard.  

    Image

  8. Save and deploy the processes.
  9. Start an instance of the first process by uploading a Word document to the first SharePoint Library.
  10. Both processes will finish without any human intervention.
  11. Open the mailbox of the person you selected the E-mail to be sent to.
  12. An E-mail will be delivered that contains the PDF document as an attachment.