This Knowledge Base article describes how to attach a PDF file to an E-mail Event in a workflow.
- Form Designers
- Views and Forms
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
KB001394 - How to attach a PDF file to an E-mail Event in a workflow using a Form Parameter
In the scenario below we are using a Form with a Save as PDF control. We then create a workflow and add a Data Field. An E-mail event is used to attach the PDF file created to the E-mail. The PDF control is then linked to the Data Field in the workflow start rule in the Rule Designer.
Follow the steps below to set up the scenario:
- Create a SmartObject to be used in a View. We used a Leave SmartObject
- Auto generate an Item View and a Form from the SmartObject
- Edit the View, remove all the buttons except for the Create button
- Rename the Create button to Submit and save the View
- Edit the Form, navigate to the Layout step and drag the Save as PDF control onto the canvas.
- Navigate to the Rules and edit the when SubmitButton is Clicked Rule
- Add the following Rule Action:
Actions: Execute a control's method
- Save the Rule
- Save the Form and create a Workflow named Leave Application from the Form
- 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 PDF File ID type which is Autonumber.
- On the Start Form screen, ensure to select the Rule when SubmitButton is Clicked. This will ensure that the data is created and the PDF is captured before starting the workflow
- Finish the wizard
- We then add a User Task to the workflow with Approve and Decline outcomes. Configure the rest of the wizard
- 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
- Map the Data Field to the Load method
- The PDF Load method is displayed in the Attachments field. Finish the wizard
- Drag a Placeholder event onto the Decline step in the workflow
- The workflow represents the following:
- Save and deploy the workflow
Edit the Form and navigate to the Rules.
Edit the when SubmitButton is Clicked Rule of the Leave Application State. This is the state that will start the workflow
- Click on configure next to the Action start the Leave Application Workflow
- Map the PDF control to the Workflow Data Field as shown below
- Save the Form
- Run the Form and capture the required details, then click Submit
- Open the worklist item, select the Action Approve and click the Submit button
- The E-mail is sent to the recipient with the PDF attached
- Open the PDF to view the details captured