> ## 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 single-document processing case

> Set up a Pega single-document case: define data-model fields and configure the send-for-processing and fetch-results stages that call FlexiCapture activities.

A single-document processing case with verification needs the standard case fields plus the invoice fields, and two 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/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega205.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=3e28d23d9369da415b291449df6c8b09" alt="Screenshot of the Workflow tab in Pega Dev Studio showing the single-document case life cycle with the Invoice received, Send for processing, Verification, and Fetching captured data stages and their steps." width="1451" height="392" data-path="images/flexi-capture/connectors/Pega205.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              |
| ------------- | --------------- | ------------------ | -------------------- |
| City          | `City`          | Text               |                      |
| Country       | `Country`       | Text               |                      |
| Currency      | `Currency`      | Text               |                      |
| InvoiceDate   | `InvoiceDate`   | Text               |                      |
| InvoiceNumber | `InvoiceNumber` | Text               |                      |
| Line Items    | `LineItems`     | Field group (list) | Data type: Line Item |
| Total         | `Total`         | Text               |                      |

For the **Line Items** data type, see [Data types for a single-document processing case](/flexi-capture/connectors/pega/pega-one-doc-data-type).

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega70.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=37589c7d9d1a4f9727182f3aa0a70f78" alt="Screenshot of the Data model tab in Pega Dev Studio showing the single-document case fields City, Country, Currency, InvoiceDate, InvoiceNumber, Line Items, and Total alongside the required Attachments, BatchId, and VerificationUrl fields." width="1208" height="632" data-path="images/flexi-capture/connectors/Pega70.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-1).
  </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/Pega71.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=b60210b78092299c8f1fcc20b18c8717" 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="723" height="830" data-path="images/flexi-capture/connectors/Pega71.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) and [The Utility step](/flexi-capture/connectors/pega/pega-stages-config#2).

<Frame>
  <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega72.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=180052018dbe66167fa36c496c4d25b8" alt="Diagram of the FetchingCapturedData_Flow process in Pega Dev Studio showing a Batch stage is processed decision that branches on its true path to a Fetching captured data step and on its false path to a Create Error step." width="1001" height="452" data-path="images/flexi-capture/connectors/Pega72.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">
    Open the step and select **Boolean Expression** in the **Type** field. Specify or configure a `@SingleDocumentBatchIsProcessed(.BatchId)` condition in the **Expression** field.

    For the function itself, see [SingleDocumentBatchIsProcessed](/flexi-capture/connectors/pega/pega-func-one-doc#singledocumentbatchisprocessed).

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

  <Step title="Configure the true branch">
    For the `true` branch, add a **Utility** step named `Fetching captured data`. Open it, call the `FetchingCapturedData` activity, and specify `.pzInsKey` in the **CaseId** field.

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

    <Frame>
      <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega74.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=a11d916997e641f5e16b7c6ed2d06ca0" alt="Screenshot of the Utility step properties in Pega Dev Studio showing the Fetching captured data step calling the FetchingCapturedData activity with .pzInsKey in the CaseId parameter." width="663" height="512" data-path="images/flexi-capture/connectors/Pega74.png" />
    </Frame>
  </Step>

  <Step title="Configure the false branch">
    For the `false` branch, add a **Utility** step named `Create Error`. Open it, call the `CreateError` activity, and specify `.pzInsKey` in the **caseId** parameter 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-1).

    <Frame>
      <img src="https://mintcdn.com/abbyy/jk6a9TGm7KRcVxRI/images/flexi-capture/connectors/Pega75.png?fit=max&auto=format&n=jk6a9TGm7KRcVxRI&q=85&s=b87a53b138baa7f6cef86116e843a1b6" 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="661" height="519" data-path="images/flexi-capture/connectors/Pega75.png" />
    </Frame>
  </Step>
</Steps>
