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

# SendForProcessing

> Configure the SendForProcessing Pega activity for a multi-document case: create a batch, add each attachment, start processing, and store the BatchId.

For more information about creating activities, see [Creating a Pega activity](/flexi-capture/connectors/pega/pega-activity-create).

## Pages & Classes

| **Page name**  | **Class**            |
| -------------- | -------------------- |
| Case           | Work-                |
| Attachment     | Data-WorkAttach-File |
| AttachmentInfo | Data-WorkAttach-File |

## Parameters

| **Name** | **Data type** | **Required** |
| -------- | ------------- | ------------ |
| CaseId   | String        | Yes          |

## Local variables

| **Name**    | **Data type** |
| ----------- | ------------- |
| LinkedRefTo | String        |
| Id          | String        |
| BatchId     | String        |

## Steps

Step 1:

**Method**: Obj-Open-By-Handle.

**Step page**: Case.

**InstanceHandle**: Param.CaseId.

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega129.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=264503b5f2e968c537e056eb862a4b3d" alt="Screenshot of step 1 in Pega configured with the Obj-Open-By-Handle method, the Case step page, and an InstanceHandle of Param.CaseId." width="1112" height="330" data-path="images/flexi-capture/connectors/Pega129.png" />
</Frame>

Step 2:

**Method**: Page-Set-Messages

**Message**: "Please add files to case before proceeding."

**When**:

| **When**          | **if true**    | **true param** | **if false** | **false param** |
| ----------------- | -------------- | -------------- | ------------ | --------------- |
| AttachmentsIsNull | Continue Whens |                | Skip Step    |                 |

<Note>
  In order to create a condition, specify *AttachmentsIsNull* in the **When** field and click the configuration button. If such a condition does not already exist, window will open where you will be able to create a new condition. Make sure that the full name of the case is specified in the **Apply to** field and click **Create and open**. On the **Conditions** tab, create the following condition: *length of .pyAttachments is Equal To 0*. To add the condition, click **Configure advanced conditions here…** and select the *length of \[a pagelist property] Is \[comparison operator] \[value]* for the condition type.
</Note>

<Frame>
  <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega206.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=832bc4ad8667169ff7d0a47d18a09233" alt="Screenshot of the Condition dialog in Pega defining the AttachmentsIsNull condition as length of .pyAttachments Is Equal To 0." width="590" height="205" data-path="images/flexi-capture/connectors/Pega206.png" />
</Frame>

**Jump**:

| **When** | **if true**   | **true param** | **if false** | **false param** |
| -------- | ------------- | -------------- | ------------ | --------------- |
| true     | Exit Activity |                |              |                 |

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega131.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=f6dac5fa332eca91b0d87004b1766f09" alt="Screenshot of step 2 in Pega using the Page-Set-Messages method, with the Message set to the text prompting the user to add files to the case before proceeding." width="1124" height="246" data-path="images/flexi-capture/connectors/Pega131.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega132.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=301dc06d8ee79e25f99a08e5ac606abc" alt="Screenshot of the When conditions dialog in Pega for step 2, with the AttachmentsIsNull condition set to Continue Whens if true and Skip Step if false." width="991" height="229" data-path="images/flexi-capture/connectors/Pega132.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega133.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=05101cb84668bb92da9eef7fb6b16015" alt="Screenshot of the Jump conditions for step 2 in Pega, with a When value of true that exits the activity." width="991" height="282" data-path="images/flexi-capture/connectors/Pega133.png" />
</Frame>

Step 3:

**Method**: Call-Function

| **Function**            | **Return value** |
| ----------------------- | ---------------- |
| @ABBYY.CreateNewBatch() | Local.BatchId    |

For more information, see [CreateNewBatch](/flexi-capture/connectors/pega/pega-func-multiple-docs#createnewbatch).

**Jump**:

| **When**       | **if true**        | **true param** | **if false** | **false param** |
| -------------- | ------------------ | -------------- | ------------ | --------------- |
| StepStatusFail | Jump to Later Step | ERR            |              |                 |

**On exception, jump to later step label**: ERR.

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega134.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=4ff42d9611966705f28822c6b6d83dae" alt="Screenshot of step 3 in Pega using the Call-Function method, with the function @ABBYY.CreateNewBatch() and a return value of Local.BatchId." width="1106" height="242" data-path="images/flexi-capture/connectors/Pega134.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega135.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=4637c13bb148f6c95a76168be96679a0" alt="Screenshot of the Jump conditions for step 3 in Pega, with a StepStatusFail condition that jumps to later step ERR if true and an on-exception label of ERR." width="989" height="279" data-path="images/flexi-capture/connectors/Pega135.png" />
</Frame>

Step 4:

**Method**: Property-Set

| **PropertiesName** | **PropertiesValue**                          |
| ------------------ | -------------------------------------------- |
| Local.LinkedRefTo  | Case.pyAttachments(\<CURRENT>).pxLinkedRefTo |
| Local.Id           | Case.pyAttachments(\<CURRENT>).pzInsKey      |

**Loop**:

| **Repeat**                     | **Value List Property** |
| ------------------------------ | ----------------------- |
| For each element in value list | Case.pyAttachments      |

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega136.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=f4a8ca8d62742c7f376f38700cc11698" alt="Screenshot of step 4 in Pega using the Property-Set method, with Local.LinkedRefTo set to the pxLinkedRefTo of the current Case.pyAttachments element and Local.Id set to its pzInsKey." width="1092" height="236" data-path="images/flexi-capture/connectors/Pega136.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega137.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=e85f94b87589d370222f6a4886ee19a0" alt="Screenshot of the Loop dialog in Pega for step 4, with Repeat set to For each element in value list and the Value List Property set to Case.pyAttachments." width="453" height="150" data-path="images/flexi-capture/connectors/Pega137.png" />
</Frame>

Substep 1:

**Method**: Obj-Open-By-Handle.

**Step page**: Attachment.

**InstanceHandle**: Local.LinkedRefTo.

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega138.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=3b89f21720558e2ce48925a0bebaf9d1" alt="Screenshot of substep 1 in Pega configured with the Obj-Open-By-Handle method, the Attachment step page, and an InstanceHandle of Local.LinkedRefTo." width="1066" height="301" data-path="images/flexi-capture/connectors/Pega138.png" />
</Frame>

Substep 2:

**Method**: Obj-Open-By-Handle.

**Step page**: AttachmentInfo.

**InstanceHandle**: Local.Id.

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega139.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=95b2eaaf9b38142afbeb68af34949462" alt="Screenshot of substep 2 in Pega configured with the Obj-Open-By-Handle method, the AttachmentInfo step page, and an InstanceHandle of Local.Id." width="1069" height="299" data-path="images/flexi-capture/connectors/Pega139.png" />
</Frame>

Substep 3:

**Method**: Call-Function

| **Function**                                                                               | **Return value** |
| ------------------------------------------------------------------------------------------ | ---------------- |
| @ABBYY.AddDocumentToBatch(Local.BatchId, AttachmentInfo.pyMemo, Attachment.pyAttachStream) |                  |

For more information, see [AddDocumentToBatch](/flexi-capture/connectors/pega/pega-func-multiple-docs#adddocumenttobatch).

**Jump**:

| **When**       | **if true**        | **true param** | **if false** | **false param** |
| -------------- | ------------------ | -------------- | ------------ | --------------- |
| StepStatusFail | Jump to Later Step | ERR            |              |                 |

**On exception, jump to later step label**: ERR.

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega140.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=72a3fbb25ece8278700433b0732c39fa" alt="Screenshot of substep 3 in Pega using the Call-Function method, with the function @ABBYY.AddDocumentToBatch(Local.BatchId, AttachmentInfo.pyMemo, Attachment.pyAttachStream) and no return value." width="1067" height="201" data-path="images/flexi-capture/connectors/Pega140.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega141.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=43fad5c2f66fe2391b73bd83dc5668f9" alt="Screenshot of the Jump conditions for substep 3 in Pega, with a StepStatusFail condition that jumps to later step ERR if true and an on-exception label of ERR." width="990" height="279" data-path="images/flexi-capture/connectors/Pega141.png" />
</Frame>

Step 5:

**Method**: Call-Function

| **Function**                             | **Return value** |
| ---------------------------------------- | ---------------- |
| @ABBYY.RunBatchProcessing(Local.BatchId) |                  |

For more information, see [RunBatchProcessing](/flexi-capture/connectors/pega/pega-func-multiple-docs#runbatchprocessing).

**Jump**:

| **When**       | **if true**        | **true param** | **if false** | **false param** |
| -------------- | ------------------ | -------------- | ------------ | --------------- |
| StepStatusFail | Jump to Later Step | ERR            |              |                 |

**On exception, jump to later step label**: ERR.

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega142.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=bfe753784aa3f6d2b6a8f565163a6730" alt="Screenshot of step 5 in Pega using the Call-Function method, with the function @ABBYY.RunBatchProcessing(Local.BatchId) and no return value." width="1095" height="202" data-path="images/flexi-capture/connectors/Pega142.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega143.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=8f2888d8319a6d80fae266b87a054b60" alt="Screenshot of the Jump conditions for step 5 in Pega, with a StepStatusFail condition that jumps to later step ERR if true and an on-exception label of ERR." width="986" height="276" data-path="images/flexi-capture/connectors/Pega143.png" />
</Frame>

Step 6:

**Method**: Call-Function

| **Function**                                                              | **Return value** |
| ------------------------------------------------------------------------- | ---------------- |
| @ABBYY.WaitFirstVerificationOrProcessedForMultiFileInvoice(Local.BatchId) | .VerificationUrl |

For more information, see [WaitFirstVerificationOrProcessedForMultiFileInvoice](/flexi-capture/connectors/pega/pega-func-multiple-docs#waitfirstverificationorprocessedformultifileinvoice).

**Jump**:

| **When**       | **if true**        | **true param** | **if false**       | **false param** |
| -------------- | ------------------ | -------------- | ------------------ | --------------- |
| StepStatusFail | Jump to Later Step | ERR            | Jump to Later Step | OK              |

**On exception, jump to later step label**: ERR.

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega144.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=00819c28fc617143f6ac143019f94d8c" alt="Screenshot of step 6 in Pega using the Call-Function method, with the function @ABBYY.WaitFirstVerificationOrProcessedForMultiFileInvoice(Local.BatchId) and a return value of .VerificationUrl." width="1084" height="196" data-path="images/flexi-capture/connectors/Pega144.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega145.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=fcf586e2ab1e6107c3b2888bddc71b36" alt="Screenshot of the Jump conditions for step 6 in Pega, with a StepStatusFail condition that jumps to later step ERR if true and OK if false, and an on-exception label of ERR." width="987" height="276" data-path="images/flexi-capture/connectors/Pega145.png" />
</Frame>

Step 7:

**Label**: ERR.

**Method**: Page-Set-Messages.

**Message**: @unescapeHTML(@getWorstMessageName(tools)).

For more information, see [unescapeHTML](/flexi-capture/connectors/pega/pega-func-other).

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega146.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=2e3b7ca6205295f551b268fb129a88bf" alt="Screenshot of step 7 in Pega labeled ERR, using the Page-Set-Messages method with the Message set to @unescapeHTML(@getWorstMessageName(tools))." width="876" height="187" data-path="images/flexi-capture/connectors/Pega146.png" />
</Frame>

Step 8:

**Label**: OK.

**Method**: Property-Set.

| **PropertiesName** | **PropertiesValue** |
| ------------------ | ------------------- |
| .BatchId           | Local.BatchId       |

<Frame>
  <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega147.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=c7d066f827fc0257c0100de2c2946d1f" alt="Screenshot of step 8 in Pega labeled OK, using the Property-Set method with a PropertiesName of .BatchId set to a PropertiesValue of Local.BatchId." width="1101" height="190" data-path="images/flexi-capture/connectors/Pega147.png" />
</Frame>
