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

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

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

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

The **Data Model** tab should have the following fields (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](/flexi-capture/connectors/pega/pega-one-doc-data-type) | LineItems     | Field group (list) | Data type: Line Item |
| Total                                                               | Total         | Text               |                      |

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

## 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 the 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-1).

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

## 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) and [Utility step](/flexi-capture/connectors/pega/pega-stages-config#2) sections.

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

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 this step and select **Boolean Expression** in the **Type** field. Specify or configure a *@SingleDocumentBatchIsProcessed(.BatchId)* condition in the **Expression** field. For more details about creating this function, 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>

4. For the *true* branch in the *Utility* step, add a step named *Fetching captured data*. To do this, open the *Utility* step and call the [FetchingCapturedData](/flexi-capture/connectors/pega/pega-fetching-captured-data-1) activity. Then, in the **CaseId** field, specify the following value: *.pzInsKey*.

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

5. For the *false* branch of the *Utility* step, add a step named *Create Error*. To do this, open the *Utility* step and call the [CreateError](/flexi-capture/connectors/pega/pega-create-error-1) activity\*.\* Then, in the *CaseId* parameter field, specify the following value: *.pzInsKey*. 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/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>
