> ## 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 the activity steps

> Build the steps and substeps for the Pega CaptureData activity that open the case attachment, call the FlexiCapture library, and apply the JSON Data Transform.

The **CaptureData** activity needs four main steps on the **Steps** tab, plus six substeps that do the processing.

## Create the main steps

<Steps>
  <Step title="Open the case">
    Create a new step and set the following fields:

    | Field              | Value                |
    | ------------------ | -------------------- |
    | **Method**         | `Obj-Open-By-Handle` |
    | **Step page**      | `Case`               |
    | **InstanceHandle** | `Param.CaseId`       |

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

  <Step title="Remove the default empty list entry">
    Create a second step and set the following fields:

    | Field                 | Value                                                          |
    | --------------------- | -------------------------------------------------------------- |
    | **Method**            | `Call RemoveFromPageList`                                      |
    | **PageListProperty**  | `LineItems`                                                    |
    | **Index**             | `1`, the index of an empty string that Pega creates by default |
    | **FinishingActivity** | `""`, an empty string                                          |

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega33.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=2fb4d2776952b454e5dfcb8872e50550" alt="Screenshot of the second step in Pega configured with the Call RemoveFromPageList method, a PageListProperty of LineItems, an Index of 1, and a FinishingActivity set to an empty string." width="876" height="343" data-path="images/flexi-capture/connectors/Pega33.png" />
    </Frame>
  </Step>

  <Step title="Initialize the index">
    Create a third step and set the following fields:

    | Field               | Value          |
    | ------------------- | -------------- |
    | **Method**          | `Property-Set` |
    | **PropertiesName**  | `Local.Index`  |
    | **PropertiesValue** | `0`            |

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega34.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=9bd9550759490690c97f60079cd4a988" alt="Screenshot of the third step in Pega configured with the Property-Set method, a PropertiesName of Local.Index, and a PropertiesValue of 0." width="799" height="195" data-path="images/flexi-capture/connectors/Pega34.png" />
    </Frame>
  </Step>

  <Step title="Get the file identifiers and file information">
    Create a fourth step, select `Property-Set` in the **Method** field, and create the `Local.LinkedRefTo` and `Local.Id` parameters:

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

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega35.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=8855dcf0a50a0906a2552e0f5434ba47" 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="790" height="234" data-path="images/flexi-capture/connectors/Pega35.png" />
    </Frame>
  </Step>
</Steps>

## Add a loop and a condition to the fourth step

Add a loop to the fourth step. Set **Repeat** to **For each element in value list** and the **Value List Property** to `Case.pyAttachments`.

<Frame>
  <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega37.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=51ce6eb8937776a26a12df269e93f59c" 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="683" height="167" data-path="images/flexi-capture/connectors/Pega37.png" />
</Frame>

Then add a **When** condition to the same step so that the activity processes only the first attachment:

| When             | if true        | if false  |
| ---------------- | -------------- | --------- |
| `Local.Index==0` | Continue Whens | Skip Step |

<Frame>
  <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega36.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=07829e1732fb7911fb68ea8f0f0c6ae9" alt="Screenshot of the When conditions dialog in Pega for step 4, with the condition Local.Index==0 set to Continue Whens if true and Skip Step if false." width="1235" height="239" data-path="images/flexi-capture/connectors/Pega36.png" />
</Frame>

## Create the six substeps

Create six substeps related to the fourth step. To create a substep, create a new step and drag it into the fourth step.

<Steps>
  <Step title="Open the attachment">
    | Field              | Value                |
    | ------------------ | -------------------- |
    | **Method**         | `Obj-Open-By-Handle` |
    | **Step page**      | `Attachment`         |
    | **InstanceHandle** | `Local.LinkedRefTo`  |

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega17.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=96060119e04b381fbc468ddd471d03d6" alt="Screenshot of the first substep in Pega configured with the Obj-Open-By-Handle method, the Attachment step page, and an InstanceHandle of Local.LinkedRefTo." width="819" height="295" data-path="images/flexi-capture/connectors/Pega17.png" />
    </Frame>
  </Step>

  <Step title="Open the attachment information">
    | Field              | Value                |
    | ------------------ | -------------------- |
    | **Method**         | `Obj-Open-By-Handle` |
    | **Step page**      | `AttachmentInfo`     |
    | **InstanceHandle** | `Local.Id`           |

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega18.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=242c6c760945d9d537e92ee1a77cd4ef" alt="Screenshot of the second substep in Pega configured with the Obj-Open-By-Handle method, the AttachmentInfo step page, and an InstanceHandle of Local.Id." width="807" height="298" data-path="images/flexi-capture/connectors/Pega18.png" />
    </Frame>
  </Step>

  <Step title="Call the connector function">
    Select `Property-Set` in the **Method** field and create the following parameters:

    | Parameter             | Value                                                                                |
    | --------------------- | ------------------------------------------------------------------------------------ |
    | `Param.jsonData`      | `@FlexiCaptureLibrary.CaptureData(AttachmentInfo.pyMemo, Attachment.pyAttachStream)` |
    | `Param.executionMode` | `DESERIALIZE`                                                                        |

    After the `@` character, specify the name of the library, and after the dot, specify the name of the function. For both, see [Create a Java function in Pega](/flexi-capture/connectors/pega/pega-installation-2#java).

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega38.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=5296633093d04dab79186538c9e9b76e" alt="Screenshot of the third substep in Pega configured with the Property-Set method, a Param.jsonData parameter set to the FlexiCaptureLibrary CaptureData function, and a Param.executionMode parameter set to DESERIALIZE." width="961" height="234" data-path="images/flexi-capture/connectors/Pega38.png" />
    </Frame>

    Then click **Jump** and add a `StepStatusFail` parameter for error handling:

    | When             | if true            | true param | if false           | false param | On exception, jump to later step label |
    | ---------------- | ------------------ | ---------- | ------------------ | ----------- | -------------------------------------- |
    | `StepStatusFail` | Jump to Later Step | `ERR`      | Jump to Later Step | `OK`        | `ERR`                                  |

    Click **Submit**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega43.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=b5579f529c06ef5e1c794851c28b0263" alt="Screenshot of the Jump conditions for the third substep 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="1087" height="301" data-path="images/flexi-capture/connectors/Pega43.png" />
    </Frame>
  </Step>

  <Step title="Handle the error messages">
    Select `Page-Set-Messages` in the **Method** field, set the `Message` parameter to `@getWorstMessageName(tools)`, and mark this substep as `ERR`.

    To stop the activity performing any subsequent steps when an error occurs, click **Jump** and add the following parameters:

    | When   | if true            | true param | if false           | false param |
    | ------ | ------------------ | ---------- | ------------------ | ----------- |
    | `true` | Jump to Later Step | `INC`      | Jump to Later Step | `INC`       |

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega44.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=d65e842c078517c37bb182739faaf577" alt="Screenshot of the Jump conditions for the fourth substep in Pega, with a When value of true that jumps to later step INC for both the if true and if false branches." width="1310" height="289" data-path="images/flexi-capture/connectors/Pega44.png" />
    </Frame>
  </Step>

  <Step title="Apply the Data Transform">
    Select `Apply-DataTransform` in the **Method** field and set the `DataTransform` parameter to `JsonToInvoiceFields`.

    Mark this substep as `OK` and select the **PassParameterPage** option.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega45.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=f52ea07c13e90049d7d0d1d3c1d197ba" alt="Screenshot of the fifth substep in Pega configured with the Apply-DataTransform method, the JsonToInvoiceFields data transform, the PassParameterPage option enabled, and labeled OK." width="794" height="198" data-path="images/flexi-capture/connectors/Pega45.png" />
    </Frame>
  </Step>

  <Step title="Increment the index">
    Select `Property-Set` in the **Method** field, create a `Local.Index` parameter, and set it to `Local.Index + 1`.

    Mark this substep as `INC`.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega46.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=2bae6c75024b5b9f9e80c297992e684b" alt="Screenshot of the sixth substep in Pega configured with the Property-Set method, a Local.Index parameter set to Local.Index plus 1, and labeled INC." width="785" height="197" data-path="images/flexi-capture/connectors/Pega46.png" />
    </Frame>
  </Step>
</Steps>

Your list of steps and substeps should now look as follows.

<Frame>
  <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega47.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=9547fe2851d7b36676a451d705461027" alt="Screenshot of the Steps tab in Pega showing the completed CaptureData activity: four top-level steps (Obj-Open-By-Handle, Call RemoveFromPageList, Property-Set, Property-Set) with six substeps under step 4 labeled ERR, OK, and INC." width="1113" height="443" data-path="images/flexi-capture/connectors/Pega47.png" />
</Frame>

## Finish the activity

<Steps>
  <Step title="Save the activity">
    Click **Save**.
  </Step>

  <Step title="Point the Utility item at the activity">
    Open the properties of the **Utility** item, select `CaptureData` in the **Rule** field, and set the **CaseId** parameter to `.pzInsKey`.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega41.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=dbfd50f514831ecb8c7949d5b6581b85" alt="Screenshot of the Utility item properties in Pega, with CaptureData selected in the Rule field and the CaseId parameter set to .pzInsKey." width="584" height="509" data-path="images/flexi-capture/connectors/Pega41.png" />
    </Frame>
  </Step>

  <Step title="Save your changes">
    Save your changes.
  </Step>
</Steps>
