> ## 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.

# Create 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.

A multi-document processing case with verification needs the standard case fields plus the fields for every Document Definition, and three configured workflow stages.

For the general procedure, see [Create a case with a workflow](/flexi-capture/connectors/pega/pega-add-case-type).

<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>

## Data model fields

Add the following fields on the **Data Model** tab, in addition to the required **Attachments**, **BatchId**, and **VerificationUrl** fields:

| Name            | Id                | Type               | Options                                                                                          |
| --------------- | ----------------- | ------------------ | ------------------------------------------------------------------------------------------------ |
| Address         | `Address`         | Field group (list) | Data type: [Address](/flexi-capture/connectors/pega/pega-many-docs-data-types#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    | `InvoiceTable`    | Field group (list) | Data type: [InvoiceTable](/flexi-capture/connectors/pega/pega-many-docs-data-types#invoicetable) |
| LastName        | `LastName`        | Text               |                                                                                                  |
| LetterDate      | `LetterDate`      | Text               |                                                                                                  |
| LetterFrom      | `LetterFrom`      | Text               |                                                                                                  |
| LetterTo        | `LetterTo`        | Text               |                                                                                                  |
| PriceCompany    | `PriceCompany`    | Text               |                                                                                                  |
| PriceTable      | `PriceTable`      | Field group (list) | Data type: [PriceTable](/flexi-capture/connectors/pega/pega-many-docs-data-types#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>

## Configure the stage that submits a document for processing

For the general procedure, see [Configure the workflow stages](/flexi-capture/connectors/pega/pega-stages-config) and [The Utility step](/flexi-capture/connectors/pega/pega-stages-config#2).

<Steps>
  <Step title="Replace the step">
    Open the **Send for processing** stage in configuration mode, replace the **Edit details** step with a **Utility** step, and name the step `Send for processing`.
  </Step>

  <Step title="Call the activity">
    Open the **Utility** step and call the `SendForProcessing` activity.

    Start creating the activity by clicking the configuration button to the right of the **Rule** field. Alternatively, leave the `pyUtilityStub` value in the **Rule** field and come back to this step after you have created the activity set.

    For more information, see [SendForProcessing](/flexi-capture/connectors/pega/pega-send-for-processing-2).
  </Step>

  <Step title="Set the case identifier">
    In the **CaseId** field, specify `.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>
  </Step>
</Steps>

## Configure the verification stage

For the general procedure, see [Configure the workflow stages](/flexi-capture/connectors/pega/pega-stages-config) and [The Utility step](/flexi-capture/connectors/pega/pega-stages-config#2).

<Steps>
  <Step title="Add the Utility step">
    Open the **Verification** stage in configuration mode, add a **Utility** step, and name it `Update Verification Url`.
  </Step>

  <Step title="Rename the existing step">
    Rename the **Edit details** step to `Verification`.
  </Step>

  <Step title="Call the activity">
    Open the **Update Verification Url** step and call the `UpdateVerificationUrl` activity.

    For more information, see [UpdateVerificationUrl](/flexi-capture/connectors/pega/pega-update-verification-url-2).
  </Step>

  <Step title="Connect the steps">
    Connect the **Verification** and **Update Verification Url** steps using a **Verification flow action** connector.

    For more information, see [Creating a flow action](/flexi-capture/connectors/pega/pega-flow-action).
  </Step>

  <Step title="Set the case identifier">
    In the **CaseId** field, specify `.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>
  </Step>
</Steps>

## Configure the stage that fetches the processing results

For the general procedure, see [Configure the workflow stages](/flexi-capture/connectors/pega/pega-stages-config), [The Utility step](/flexi-capture/connectors/pega/pega-stages-config#2), and [The Decision step](/flexi-capture/connectors/pega/pega-stages-config#3).

<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>

<Steps>
  <Step title="Delete the existing step">
    Open the **Fetching captured data** stage in configuration mode and delete the **Edit details** step.
  </Step>

  <Step title="Add a Decision step">
    Add a **Decision** step and name it `Batch stage is processed`.
  </Step>

  <Step title="Set the decision expression">
    1. Open the step and select **Boolean Expression** in the **Type** field.
    2. In the **Expression** field, enter or configure a `@MultiDocumentBatchIsProcessed(.BatchId)` condition.
    3. Click **Submit**.

    For the function itself, 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>
  </Step>

  <Step title="Configure the true branch">
    For the `true` branch, create one **Utility** step per Document Definition. For each step, call the `FetchingCapturedData` activity, enter `.pzInsKey` in the **caseId** field, and set **templateName** to the matching value:

    | Utility step name        | templateName   |
    | ------------------------ | -------------- |
    | `Fetching Invoice data`  | `Invoice_eng`  |
    | `Fetching Banking data`  | `Banking_eng`  |
    | `Fetching Contract data` | `Contract_eng` |
    | `Fetching Letter data`   | `Letter_eng`   |
    | `Fetching Price data`    | `Price_eng`    |

    For more information, see [FetchingCapturedData](/flexi-capture/connectors/pega/pega-fetching-captured-data-2).

    <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>
  </Step>

  <Step title="Configure the false branch">
    For the `false` branch, create a **Utility** step named `Create Error`, call the `CreateError` activity, and enter `.pzInsKey` in the **caseId** field.

    In the **errorMessage** field, enter this text:

    ```text theme={null}
    Please complete the verification task before proceeding.
    ```

    For more information, see [CreateError](/flexi-capture/connectors/pega/pega-create-error-2).

    <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>
  </Step>
</Steps>
