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

Next, you need to create steps for the *CaptureData* activity.

1. On the **Steps** tab, create a new step and for this step: in the **Method** field, select *Obj-Open-By-Handle*; in the **Step page** field, select *Case*; and in the **InstanceHandle** field, type *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>

2. Create a second step and for this step: in the **Method** field, select *Call RemoveFromPageList;* in the **PageListProperty** field, type *LineItems;* in the **Index** field, type **1** (i.e. the index of an empty string that Pega creates by default); and in the **FinishingActivity** field, type *""* (i.e. 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>

3. Create a third step and for this step: in the **Method** field, select *Property-Set;* in the **PropertiesName** field, select *Local.Index;* and in the **PropertiesValue** field, type *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>

4. Create a fourth step that will get file identifiers and information about files. For this step, select *Property-Set* in the **Method** field and create the following parameters: *Local.LinkedRefTo* and *Local.Id*.

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

5. Add the following loop to step 4: *For each element in value list – 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>

6. Add a *When* condition to step 4 and set this condition to *Local.Index==0.* This will cause the activity to process 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>

7. Create six substeps related to step 4 (to create a substep, create a new step and drag into step 4).
   * For the first substep: in the **Method** field, select *Obj-Open-By-Handle*; in the **Step page** field, select *Attachment*; and in the **InstanceHandle** field, type *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>

* For the second substep: in the **Method** field, select *Obj-Open-By-Handle*; in the **Step page** field, select *AttachmentInfo*; and in the **InstanceHandle** field, type *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>

* For the third substep, select *Property-Set* in the **Method** field and create the following parameter for this method: *Param.jsonData – @FlexiCaptureLlibrary.CaptureData(AttachmentInfo.pyMemo, Attachment.pyAttachStream)* (after the "@" character, specify the name of the library described in the [Installation](/flexi-capture/connectors/pega/pega-installation-2#java) section; after the dot, specify the name of the function). Additionally, create a parameter named *Param.executionMode – DESERIALIZE*.

  <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 @FlexiCaptureLibrary.CaptureData(AttachmentInfo.pyMemo, Attachment.pyAttachStream), and a Param.executionMode parameter set to DESERIALIZE." width="961" height="234" data-path="images/flexi-capture/connectors/Pega38.png" />
  </Frame>

Next, click the **Jump** button 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                                        |

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

Click **Submit**.

* For the fourth substep, select *Page-Set-Messages* in the **Method** field and specify the following parameter for this method: *Message – @getWorstMessageName(tools).* Mark this substep as *ERR*. Next, you need to prevent the activity from performing any subsequent steps if an error occurs. To do this, click the **Jump** button 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>

* For the fifth substep select *Apply-DataTransform* in the **Method** field and specify the following parameter for this method: *DataTransform – 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>

* For the sixth substep, select *Property-Set* in the **Method** field, create a *Local.Index* parameter for this method, and set this parameter 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+ 1, and labeled INC." width="785" height="197" data-path="images/flexi-capture/connectors/Pega46.png" />
</Frame>

At this point, your list of steps and substeps should 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>

8. Click **Save**.

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

10. Save your changes.
