This Knowledge Base article describes how to attach a PDF file to an E-mail Event in a workflow using a Form Parameter.
- 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
KB001392 - How to attach a PDF file to an E-mail Event in a workflow
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:
- Create a SmartObject to be used in a View. We used a Quote 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 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.
- Navigate to the Rules and edit the when SubmitButton is Clicked Rule
- Add the following Rule Actions:
Actions: Execute a control's method
Actions: Transfer data
Actions: Show a message
- 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
- 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"
- Save the Form and create a Workflow called Quote Approval 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 Parameter Type used in the Form when the PDF Parameter was created earlier in the scenario.
- 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
- Next map the Form Parameter to the Workflow Data Field as shown below and 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 outcome in the workflow
- The workflow represent the following:
- Save and deploy the workflow
- Run the Form and capture the required details then click the Submit button
- Open the worklist item, select the Approve Action 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