Table of Contents

Use case: Send file attachments from a repository

You are running an insurance claim case for a car insurance company. You must send a payment request to the insurance carrier of the driver who hit the car that belongs to your client.

The payment request for this case is stored as a PDF file in the PaymentRequests repository on your company system.

The following sections describe the components of the configuration that your application needs to retrieve the PDF file from the PaymentRequests repository and send the payment request to an external system.

UploadPaymentRequest activity

The UploadPaymentRequest activity explains how to retrieve the PDF file and send it by using a REST connector. You use this activity to construct the pyRequestAttachmentPage and call the REST connector.

For more information, see Creating an activity.

The following image shows a sample of the UploadPaymentRequest activity configuration:

UploadPaymentRequest activity configuration
Sample of the UploadPaymentRequest activity configuration


The pyRequestAttachmentPage page is a clipboard page where the REST connector formats the outgoing message payload. In this case, the payload is the contents of the payment request PDF file. You create the pyRequestAttachmentPage by configuring a Page-New method in the UploadPaymentRequests activity.

For more information, see Activity form - Completing the Steps tab - Entering Method parameters and the Page-New method.

You also must add the pyRequestAttachmentPage and its class to the Pages & Classes tab of the UploadPaymentRequest activity, so that the activity knows which page to create at run time.

For more information, see File attachment configuration in REST and SOAP integrations and Defining the pages and classes of a rule.

GetFileFromRepository activity

To specify the file you are retrieving and the repository where the file is located, you call the GetFileFromRepository activity from the UploadPaymentRequest activity. To retrieve multiple files from a repository, you can call the GetFileFromRepository activity from multiple steps.

For more information, see Call-Function.

Repository configuration
Sample of configuring the repository in the UploadPaymentRequest

Properties on the pyRequestAttachmentPage

The properties on the pyRequestAttachmentPage map to the MIME headers in the partitions of the outgoing REST message payload. The payload for the payment request resembles the following example:
Content-Disposition: form-data; name="InsurancePaymentRequest.pdf"; filename=" InsurancePaymentRequest.pdf"
Content-Type: application/pdf
Content-Transfer-Encoding: binary

The following table shows the properties that you configure on the pyRequestAttachmentPage and which headers they map to.

Properties MIME headers
pyAttachNames name="InsurancePaymentRequest.pdf"
pyAttachFileNames filename=" InsurancePaymentRequest.pdf"
pyAttachTypes Content-Type: application/pdf
You can use the pxGetMimetypeFromFileName utility function to convert file extensions to their corresponding MIME types.

You configure the values for these properties in the GetFileFromRepository activity. Use the Property-Set method and enter the property names and values as method parameters.

For more information, see Property-Set method.

D_pxGetFile data page

The Pega-provided D_pxGetFile data page retrieves the file content from the PaymentRequests repository. The pyContents property value from the data page is appended to the pyAttachValues value list property on the pyRequestAttachmentPage. The pyAttachValues value list property is configured in the GetFileFromRepository activity as follows:
pyContents configuration
Sample of configuring properties in the GetFileFromRepository

For more information, see Get file API.

REST connector

The REST connector finds the pyRequestAttachmentPage and formats the outgoing message payload. You call the REST connector from the UploadPaymentRequest activity by using the Connect-REST method.

When you configure the REST connector, on the Methods tab of the rule form, make sure that the request message body Map from and Map from key fields are blank.

After it invokes the REST connector rule, the UploadPaymentRequest activity uses the Page-Remove method to remove the pyRequestAttachmentPage from the clipboard.

For more information, see Connect-REST method and Page-Remove method.

Next: Learn how to process the PDF file that the insurance carrier returns. For more information, see Use case: Process inbound file attachments for storage in a repository.
Did you find this content helpful?

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.