Support Article
PDF attached to case but missing in email attachment by category
SA-91279
Summary
On click of a button to generate a PDF and sending it to the required mail ID, the generated PDF is attached to the work object. However, it is missing as an attachment in the email that is sent.
On clicking the button the second time, a new PDF is generated and attached to the work object along with the earlier PDF. However, only the first PDF is sent as an attachment.
This occurs on every click of the button and n-1 PDFs are sent in the mail as an attachment (where n is the number of PDFs generated and attached to the work object).
Error Messages
Not Applicable
Steps to Reproduce
- Create an activity.
- Invoke the pyAttachAsPDF in Step 1 of the activity to generate and attach the PDF to the work object.
- Invoke the SendSimpleEmail in Step 2 of the activity to send the attached PDF to the required mail ID.
- Configure a button in the case.
- Invoke the activity on the click of the button.
- Execute the case.
- Click the button. The PDF is attached to the work object. However, the PDF is not sent in the mail as an attachment.
- Reclick the button. The new PDF is attached to the work object along with the older PDF. However, only the first PDF is sent as an attachment.
Root Cause
On the third step of the pyAttachAsPDF activity, Code-Pega-PDF.AttachToWork is invoked to attach the PDF to a work object. After attaching the PDF to the work object, the pyAttachment page list is flushed. The pyAttachment property refers to the D_AttachmentList data page which contains all the attachments of the current work object.
Since pyAttachment is flushed, the current attachment is not present before the SendSimpleEmail is invoked. Hence, the pyAttachment must be reloaded to fetch all the attachments of the current work object.
Resolution
Perform the following local-change:
Add the step as below @SizeOfPropertyList(.pyAttachments) after Call pyAttachAsPdf and before Call SendSimpleEmail to reload the pyAttachment to fetch and store the PDF generated currently.
Published February 15, 2020 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.