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

# Install the Pega connector for the verification scenario

> Install the ABBYY FlexiCapture connector on a Pega server: import the JAR, create a library with packages and static variables, and define functions.

Installing the ABBYY FlexiCapture Connector for Pega takes three parts: importing the connector, creating a library, and creating the functions that call it.

<h2 id="import">
  Import the connector to the Pega server
</h2>

<Steps>
  <Step title="Open the Import wizard">
    Open **Dev Studio** and click **Configure → Application → Distribution → Import**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/Pega1.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=a341f96a004c8a19fb49207d18680709" alt="Screenshot of Pega Dev Studio with the Configure menu open, showing the Application → Distribution → Import path being selected to import the connector." width="935" height="329" data-path="images/flexi-capture/connectors/Pega1.png" />
    </Frame>
  </Step>

  <Step title="Load the connector">
    Load the `abbyy.flexicapture.webapi.client.jar` file on to the server.
  </Step>

  <Step title="Restart the server">
    Open the **Pega Self-Service Portal** and click **Restart Server**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega2.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=eecde34cbec1e5bd944b2b7b9ae52933" alt="Screenshot of the Pega Self-Service Portal Operations page with the Restart Server button highlighted to restart the application server." width="537" height="297" data-path="images/flexi-capture/connectors/Pega2.png" />
    </Frame>
  </Step>
</Steps>

<h2 id="lib">
  Create a library
</h2>

<Steps>
  <Step title="Start a new library">
    Click **Records → Technical → Library → Create**.
  </Step>

  <Step title="Name the library">
    On the **Create Library** tab, specify a name for the library in the **Label** field, for example `ABBYY`, and fill in the **Identifier** field.

    Make sure that the library is being created within the context of your application, and then click **Create and open**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega52.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=3ca766b1ed9d2c5b38309ae1a1712219" alt="Screenshot of the Pega Create Library form with ABBYY entered in the Label and Identifier fields and FlexiCapture for Invoices selected as the application context." width="1227" height="429" data-path="images/flexi-capture/connectors/Pega52.png" />
    </Frame>
  </Step>

  <Step title="Add the packages">
    On the **Packages** tab, add the following packages:

    * `java.util.*`
    * `java.nio.file.*`
    * `java.net.*`
    * `java.lang.*`
    * `java.util.stream.*`
    * `org.apache.commons.lang3.*`
    * `abbyy.flexicapture.webapi.client.*`
    * `abbyy.flexicapture.webapi.client.api.*`
    * `abbyy.flexicapture.webapi.client.models.*`

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega53.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=0176835eae98534710c3ae9402e84117" alt="Screenshot of Pega Dev Studio on the library Packages tab, listing the nine Java packages to include, including the abbyy.flexicapture.webapi.client packages, alongside the Generate Library button." width="601" height="702" data-path="images/flexi-capture/connectors/Pega53.png" />
    </Frame>
  </Step>

  <Step title="Create the static variables">
    On the **Static Variables** tab, create the following string variables:

    * `baseUri`
    * `tenantName`
    * `userName`
    * `password`
    * `multiFileProjectName`
    * `singleFileProjectName`

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega54.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=eccb393f811a02438cfc1de83cf4032c" alt="Screenshot of Pega Dev Studio on the library Static Variables tab, showing the baseUri, tenantName, userName, password, multiFileProjectName, and singleFileProjectName String variables and their sample values." width="844" height="412" data-path="images/flexi-capture/connectors/Pega54.png" />
    </Frame>
  </Step>

  <Step title="Generate the library">
    Click **Save**, and then click **Generate Library**.
  </Step>
</Steps>

<h2 id="func">
  Create a function
</h2>

A function holds Java code that runs when the function is called from other Pega objects. Specify the input and output parameters on the **Parameters** tab, and the exceptions on the **Imports & Exceptions** tab.

<Steps>
  <Step title="Start a new function">
    Click **Records → Technical → Function → Create** and fill in the **Label** and **Identifier** fields.
  </Step>

  <Step title="Select the library">
    In the **Library** field, specify the name of the library you created earlier.
  </Step>

  <Step title="Specify the input parameters">
    In the **Parameters** section, specify the following two input parameters:

    | Name            | Java type |
    | --------------- | --------- |
    | `FileName`      | `String`  |
    | `Base64Content` | `String`  |
  </Step>

  <Step title="Create the function">
    Make sure that the function is being created within the context of your application, and then click **Create and open**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega55.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=31cfe52be7c6f5dafac9590265e87b98" alt="Screenshot of the Pega Create Function form with SendForProcessing in the Label field, the ABBYY library selected, the fileName and base64Content String parameters listed, and FlexiCapture for Invoices selected as the application context." width="819" height="471" data-path="images/flexi-capture/connectors/Pega55.png" />
    </Frame>
  </Step>

  <Step title="Set the output data type">
    In the window that opens, on the **Parameters** tab, specify `int`, `string`, or `boolean` as the data type in the **Java data type** field.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega56.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=3a4b847cb643cb18d26c637c4bdfbede" alt="Screenshot of Pega Dev Studio on the function Parameters tab, showing the fileName and base64Content String input parameters and int entered as the Java data type in the Output section." width="1455" height="667" data-path="images/flexi-capture/connectors/Pega56.png" />
    </Frame>
  </Step>

  <Step title="Declare the thrown exception">
    Click the **Imports & Exceptions** tab and type `Exception` in the **Exceptions thrown** section.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega57.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=3be1a89418a95c69bbb6d6ab3621aca7" alt="Screenshot of Pega Dev Studio on the function Imports and Exceptions tab, showing Exception entered in the Exceptions thrown section." width="571" height="288" data-path="images/flexi-capture/connectors/Pega57.png" />
    </Frame>
  </Step>

  <Step title="Add the code and generate the function">
    Go back to the **Java** tab and insert the code for the function in the **Java source** field. Select the **Function ready to be compiled?** option, save your changes, and then click **Generate function**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/Xgx3EG8BZs5YQjIJ/images/flexi-capture/connectors/Pega58.png?fit=max&auto=format&n=Xgx3EG8BZs5YQjIJ&q=85&s=d81b7efb0a7f8d87df6ef3325ea26832" alt="Screenshot of Pega Dev Studio on the function Java tab, showing the Function ready to be compiled option selected, the Generate function button, and the Java source code that creates a FlexiCapture batch and returns its identifier." width="1014" height="720" data-path="images/flexi-capture/connectors/Pega58.png" />
    </Frame>
  </Step>
</Steps>

## Where the function code comes from

Copy the code for each function from the Java file in this folder:

```text theme={null}
%Installation Path%\Connector for FlexiCapture as a Service with verification\Samples\Code examples\Pega Functions
```

The functions each scenario needs are listed in [Create the functions for single-document processing](/flexi-capture/connectors/pega/pega-func-one-doc) and [Create the functions for multi-document processing](/flexi-capture/connectors/pega/pega-func-multiple-docs), along with the general functions in [Create the general functions](/flexi-capture/connectors/pega/pega-func-other).

## Next steps

For the full sequence of steps for your scenario, see [ABBYY FlexiCapture as a service with verification](/flexi-capture/connectors/pega-fc-as-service-verification).
