The latest How To topics are available in the K2 Five User Guide or the K2 Cloud User Guide’s How to section.

This Knowledge Base article describes how to attach a PDF file to an E-mail Event in a workflow using a Form Parameter.

  • Developers
  • Form Designers
Required Knowledge
  • Views and Forms
  • Rules
  • Controls
  • Workflow

A PDF file can be created using the Save as PDF control. For more information on the Save as PDF control, see the following Knowledge Base articles :

KB001361 - How to use Rule Actions to execute a custom control method

KB001378 - How to use the synchronous and asynchronous execution options of the Save as PDF control 

KB001392 - How to attach a PDF file to an E-mail Event in a workflow

Example Scenario

In the scenario below we are using a Form with a Save as PDF control. We are using a Form Parameter and Rules to save the details of the Save as PDF control. We then create a workflow and map the Parameter to a Data Field which is then used to link the PDF details. An E-mail event is used to attach the PDF file created to the E-mail. 

Follow the steps below to set up the scenario:

  1. Create a SmartObject to be used in a View. We used a Quote SmartObject
  2. Auto generate an Item View and a Form from the SmartObject
  3. Edit the View, remove all the buttons except for the Create button
  4. Rename the Create button to Submit and save the View
  5. Edit the Form, navigate to the Layout step and drag the Save as PDF control onto the canvas.
  6. Navigate to the Parameters and add a Parameter for the PDF called PDF ID. The Data Type should be Number. It is important to note that the PDF value will not necessarily represent a Number value and the Parameter type used must correlate to the ID Data Field type used in the workflow shown later in this scenario.  
  7. Navigate to the Rules and edit the when SubmitButton is Clicked Rule
  8. Add the following Rule Actions:
    Actions: Execute a control's method
    Actions: Transfer data
    Actions: Show a message
  9. On the Transfer Data Action, click on configure and map the Save as PDF control to the Parameter as shown below. When mapping the Save As PDF token in the RuleDesigner it represents the PDF ID  
  10. Configure the message by clicking on configure next to the show a message to the user Action. The message could be something like "Submitted successfully"
  11. Save the Form and create a Workflow called Quote Approval from the Form
  12. On the Data Fields screen of the Workflow Settings, create a Data Field of Type Integer as shown below. The Type used here should correlate to the Parameter Type used in the Form when the PDF Parameter was created earlier in the scenario.  
  13. On the Start Form screen, select the Rule when SubmitButton is Clicked. This will ensure that the data is created and the PDF is captured before starting the workflow 
  14. Next map the Form Parameter to the Workflow Data Field as shown below and finish the wizard
  15. We then add a User Task to the workflow with Approve and Decline outcomes. Configure the rest of the wizard
  16. Drag the Send E-mail event onto the Approve outcome. Provide details and then drag the PDF Load method into the Attachments field as shown below  
  17. Map the Data Field to the Load method 
  18. The PDF Load method is displayed in the Attachments field. Finish the wizard 
  19. Drag a Placeholder event onto the Decline outcome in the workflow
  20. The workflow represent the following:
  21. Save and deploy the workflow
  22. Run the Form and capture the required details then click the Submit button
  23. Open the worklist item, select the Approve Action and click the Submit button
  24. The E-mail is sent to the recipient with the PDF attached
  25. Open the PDF to view the details captured