> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a multi-document processing case

> Configure a Pega multi-document case: set up data-model fields plus the send-for-processing, verification, and fetch-results stages for FlexiCapture.

For more details about creating cases, see [Creating a case with a workflow](/flexi-capture/connectors/pega/pega-add-case-type).

A configured workflow for processing multiple documents should look as follows:

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega88.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=8b2bc38a75a09517d614ba533bfc9517" alt="Diagram of the FetchingCapturedData_Flow process showing a Batch stage is processed decision that branches on its true path through the Fetching Invoice, Banking, Contract, Letter, and Price data steps and on its false path through a Create Error step." width="1484" height="325" data-path="images/flexi-capture/connectors/Pega88.png" />
</Frame>

For a multi-document processing case that includes verification, the **Workflow** tab should look as follows:

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega83.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=c72da61d1156ba655dfdc72e8a7afc3e" alt="Screenshot of the Workflow tab in Pega Dev Studio showing the multi-document case life cycle with the Invoice received, Send for processing, Verification, and Fetching captured data stages and their steps." width="1326" height="545" data-path="images/flexi-capture/connectors/Pega83.png" />
</Frame>

The **Data Model** tab should have the following fields (in addition to the required *Attachments*, *BatchId,* and *VerificationUrl* fields):

| **Name**                                                                              | **Id**          | **Type**           | **Options**             |
| ------------------------------------------------------------------------------------- | --------------- | ------------------ | ----------------------- |
| [Address](/flexi-capture/connectors/pega/pega-many-docs-data-types#address)           | Address         | Field group (list) | Data type: Address      |
| BirthDate                                                                             | BirthDate       | Text               |                         |
| City                                                                                  | City            | Text               |                         |
| ContractDate                                                                          | ContractDate    | Text               |                         |
| ContractNumber                                                                        | ContractNumber  | Text               |                         |
| DeliveryAddress                                                                       | DeliveryAddress | Text               |                         |
| EmployerName                                                                          | EmployerName    | Text               |                         |
| FirstName                                                                             | FirstName       | Text               |                         |
| HomePhone                                                                             | HomePhone       | Text               |                         |
| Initial                                                                               | Initial         | Text               |                         |
| InvoiceCompany                                                                        | InvoiceCompany  | Text               |                         |
| InvoiceDate                                                                           | InvoiceDate     | Text               |                         |
| InvoiceNumber                                                                         | InvoiceNumber   | Text               |                         |
| [InvoiceTable](/flexi-capture/connectors/pega/pega-many-docs-data-types#invoicetable) | InvoiceTable    | Field group (list) | Data type: InvoiceTable |
| LastName                                                                              | LastName        | Text               |                         |
| LetterDate                                                                            | LetterDate      | Text               |                         |
| LetterFrom                                                                            | LetterFrom      | Text               |                         |
| LetterTo                                                                              | LetterTo        | Text               |                         |
| PriceCompany                                                                          | PriceCompany    | Text               |                         |
| [PriceTable](/flexi-capture/connectors/pega/pega-many-docs-data-types#pricetable)     | PriceTable      | Field group (list) | Data type: PriceTable   |
| SSN                                                                                   | SSN             | Text               |                         |
| Total                                                                                 | Total           | Text               |                         |
| WorkPhone                                                                             | WorkPhone       | Text               |                         |

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega84.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=d9d07ff0dcd505e0b5c12a1eff303fcf" alt="Screenshot of the Data model tab in Pega Dev Studio showing the full list of multi-document case fields, including Address, InvoiceTable, and PriceTable field groups alongside the required Attachments, BatchId, and VerificationUrl fields." width="836" height="1278" data-path="images/flexi-capture/connectors/Pega84.png" />
</Frame>

## Configuring a stage that will submit a document for processing

For more detailed instructions, see the [Configuring workflow stages](/flexi-capture/connectors/pega/pega-stages-config) and [Utility step](/flexi-capture/connectors/pega/pega-stages-config#2) sections.

1. Open the *Send for processing* stage in configuration mode, replace the *Edit details* step with a *Utility* step, and specify the following name for this step: *Send for processing*.
2. Open the *Utility* step and call the *SendForProcessing* activity. For more details about creating this activity, see [SendForProcessing](/flexi-capture/connectors/pega/pega-send-for-processing-2).

<Note>
  You can begin creating an activity by clicking the configuration button to the right of the **Rule** field. Alternatively, you can leave the *pyUtilityStub* value specified in the **Rule** field and come back to this step after you have created an activity set.
</Note>

3. In the **CaseId** field, specify the following: *.pzInsKey.*

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega85.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=ea23edd699135673d844c74e698ec27a" alt="Screenshot of the SendForProcessing_Flow diagram and Utility step properties in Pega Dev Studio showing the Send for processing utility calling the SendForProcessing activity with .pzInsKey in the CaseId parameter." width="675" height="755" data-path="images/flexi-capture/connectors/Pega85.png" />
</Frame>

## Configuring a verification stage

For more detailed instructions, see the [Configuring workflow stages](/flexi-capture/connectors/pega/pega-stages-config) and [Utility step](/flexi-capture/connectors/pega/pega-stages-config#2) sections.

1. Open the *Verification* stage in configuration mode, add a *Utility* step, and set its name to be *Update Verification Url*.
2. Rename the *Edit details* step to *Verification*.
3. Open the *Update Verification Url* step and call the *UpdateVerificationUrl* activity. For more details about creating an activity for a multi-document case, see [UpdateVerificationUrl](/flexi-capture/connectors/pega/pega-update-verification-url-2).
4. Connect the *Verification* and *Update Verification Url* steps using a **Verification flow action** connector. For more information about creating a flow action, see [Creating a flow action](/flexi-capture/connectors/pega/pega-flow-action).
5. In the **CaseId** field, specify the following: *.pzInsKey.*

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega86.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=d9c5d0f0955745e6268784e52466dc3a" alt="Screenshot of the WaitingForVerification_Flow diagram in Pega Dev Studio showing the Verification connector properties and the Update Verification Url utility step calling the UpdateVerificationUrl activity with .pzInsKey in the caseId parameter." width="1240" height="755" data-path="images/flexi-capture/connectors/Pega86.png" />
</Frame>

## Configuring a stage that will fetch the processing results

For more detailed instructions, see the [Configuring workflow stages](/flexi-capture/connectors/pega/pega-stages-config), [Utility step](/flexi-capture/connectors/pega/pega-stages-config#2), and [Decision step](/flexi-capture/connectors/pega/pega-stages-config#3) sections.

1. Open the *Fetching captured data* stage in configuration mode and delete the *Edit details* step.

2. Add a *Decision* step and name it *Batch stage is processed*.

3. Open the step and select *Boolean Expression* in the **Type** field.

4. In the **Expression** field, enter or configure a *@MultiDocumentBatchIsProcessed(.BatchId)* condition. For more details about creating this function, see [MultiDocumentBatchIsProcessed](/flexi-capture/connectors/pega/pega-func-multiple-docs#multidocumentbatchisprocessed).

   <Frame>
     <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega87.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=16e26aa3cc0a820919e90df95679d5e0" alt="Screenshot of the Decision step properties in Pega Dev Studio showing the Batch stage is processed decision with Boolean Expression selected and the @MultiDocumentBatchIsProcessed(.BatchId) expression entered." width="706" height="408" data-path="images/flexi-capture/connectors/Pega87.png" />
   </Frame>

5. Click **Submit**.

6. Create a *Utility* step named *Fetching Invoice data* for the *true* branch and call the *FetchingCapturedData* activity. For more information about creating this activity, see [FetchingCapturedData](/flexi-capture/connectors/pega/pega-fetching-captured-data-2).

7. Enter *.pzInsKey* in the **caseId** field and *Invoice\_eng* in the **templateName** field.

   <Frame>
     <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega89.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=fe72d6ba3c1deab9d30e22e987e57ee7" alt="Screenshot of the Utility step properties in Pega Dev Studio showing the Fetching Invoice data step calling the FetchingCapturedData activity with .pzInsKey in caseId and Invoice_eng in templateName." width="671" height="518" data-path="images/flexi-capture/connectors/Pega89.png" />
   </Frame>

8. For the *true* branch, create a *Utility* step named *Fetching Banking data* and call the *FetchingCapturedData* activity.

9. Enter *.pzInsKey* in the **caseId** field and *Banking\_eng* in the **templateName** field.

   <Frame>
     <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega90.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=f907e68cfbbb480b1e577fc6e7f9b5e6" alt="Screenshot of the Utility step properties in Pega Dev Studio showing the Fetching Banking data step calling the FetchingCapturedData activity with .pzInsKey in caseId and Banking_eng in templateName." width="662" height="514" data-path="images/flexi-capture/connectors/Pega90.png" />
   </Frame>

10. For the *true* branch, create a *Utility* step named *Fetching Contract data* and call the *FetchingCapturedData* activity.

11. Enter *.pzInsKey* in the **caseId** field and *Contract\_eng* in the **templateName** field.

    <Frame>
      <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega91.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=7cf524056421bcb34463fdd2f526b85d" alt="Screenshot of the Utility step properties in Pega Dev Studio showing the Fetching Contract data step calling the FetchingCapturedData activity with .pzInsKey in caseId and Contract_eng in templateName." width="670" height="513" data-path="images/flexi-capture/connectors/Pega91.png" />
    </Frame>

12. For the *true* branch, create a *Utility* step named *Fetching Letter data* and call the *FetchingCapturedData* activity.

13. Enter *.pzInsKey* in the **caseId** field and *Letter\_eng* in the **templateName** field.

    <Frame>
      <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega92.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=8c0950a0562dab52bbb01c5bd74c3564" alt="Screenshot of the Utility step properties in Pega Dev Studio showing the Fetching Letter data step calling the FetchingCapturedData activity with .pzInsKey in caseId and Letter_eng in templateName." width="668" height="514" data-path="images/flexi-capture/connectors/Pega92.png" />
    </Frame>

14. For the *true* branch, create a *Utility* step named *Fetching Price data* and call the *FetchingCapturedData* activity.

15. Enter *.pzInsKey* in the **caseId** field and *Price\_eng* in the **templateName** field.

    <Frame>
      <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega93.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=9548c0e6cbe49f3d80c12dc2bfacaefe" alt="Screenshot of the Utility step properties in Pega Dev Studio showing the Fetching Price data step calling the FetchingCapturedData activity with .pzInsKey in caseId and Price_eng in templateName." width="672" height="514" data-path="images/flexi-capture/connectors/Pega93.png" />
    </Frame>

16. For the *false* branch, create a *Utility* step named *Create Error* and call the *CreateError* activity. For more details about creating this activity, see [CreateError](/flexi-capture/connectors/pega/pega-create-error-2).

17. Enter *.pzInsKey* in the **caseId** field. In the **errorMessage** field, enter the following text: *"Please complete the verification task before proceeding."*

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega94.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=97bb6c2b7fd900fd62827f477d98647f" alt="Screenshot of the Utility step properties in Pega Dev Studio showing the Create Error step calling the CreateError activity with .pzInsKey in caseId and the verification reminder text in the errorMessage parameter." width="665" height="511" data-path="images/flexi-capture/connectors/Pega94.png" />
</Frame>
