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

# Modify the ABBYYFlexiCapture application

> Add a record type to the sample ABBYYFlexiCapture application by creating a data type, data source, data store, constant, and knowledge center.

You can modify the sample ABBYYFlexiCapture application to store a different type of document. To do so, create a new record type and make several other changes.

## Create an infrastructure for storing and displaying data in Appian

A record type displays information from the data store in Tempo.

To store and display a new type of data in Appian, build the supporting infrastructure by completing these tasks in order:

1. [Create a database table (data type)](#datatype).
2. [Create a data source](#datasource).
3. [Create a data store](#datastore).
4. [Create a record type](#recordtype).
5. [Create a constant of type "Data Store Entity"](#datastoreentity) to link the data store and the data type.
6. [Edit the `AFC_GetDataTypeByRecordTypeName` and `AFC_GetConstantDSEByRecordTypeName` rules](#rulesedit).
7. [Create a folder of type "Knowledge Center"](#knowledgecenter) to store processed files received from ABBYY FlexiCapture.

### <a id="datatype" />Create a data type

<Steps>
  <Step title="Open the ABBYYFlexiCapture application">
    In Appian Designer, open the ABBYYFlexiCapture application and click **New → Data Type**.
  </Step>

  <Step title="Create the data type">
    Select **Create from scratch**, complete the required **Name** field, and click **Create & Edit**.
  </Step>

  <Step title="Add the table fields">
    In the dialog box that opens, create the database table fields by clicking the **New Field** button. The ABBYY FlexiCapture Connector for Appian populates this table with data, and then the record loads data from this table into Appian.

    <Warning>
      The table must contain a primary key field named `FolderId` of type `Number(Integer)`. This field functions as a unique primary key and links the data in the table with the knowledge center folder.
    </Warning>
  </Step>

  <Step title="Add an auxiliary data type for table columns">
    1. Before the data type table in Appian can accept table rows from ABBYY FlexiCapture, create an auxiliary data type for the fields that correspond to table columns in the Document Definition.
    2. Create a field in the data type, specify the name of the auxiliary data type as its type, and select the **Array** option.
  </Step>

  <Step title="Save the data type">
    When you have made all the necessary changes to the table, click **Save**.
  </Step>
</Steps>

### <a id="datasource" />Create a data source

<Steps>
  <Step title="Open the Data Sources page">
    Open the Appian Administration Console and click **Data Sources** in the **Integration** section on the left.
  </Step>

  <Step title="Start a new data source">
    On the **Data Source Management** page that opens, click **New Data Source**.
  </Step>

  <Step title="Complete the data source fields">
    In the **Configure Data Source** dialog box, complete the following required fields:

    * **Name** – A name for the new data source (for example, `jdbc/Appian`)
    * **Type** – The type of the new data source (for example, `SQL Server`)
    * **Username/Password** – The credentials of the database user
    * **Connection String** – The string used to connect to the database (for example, `jdbc:sqlserver://appian.company.com:1433;databaseName=appian_db`)
  </Step>

  <Step title="Test and save the connection">
    1. Click **Test Connection** to check that you have entered the correct data.
    2. If the test is successful, click **Save**.
  </Step>
</Steps>

### <a id="datastore" />Create a data store

<Steps>
  <Step title="Open the ABBYYFlexiCapture application">
    In Appian Designer, open the ABBYYFlexiCapture application and click **New → Data Store**.
  </Step>

  <Step title="Name the data store">
    Complete the **Name** field and click **Create & Edit**.
  </Step>

  <Step title="Configure the data store on the Data Management tab">
    On the **Data Management** tab of the Data Store editor:

    1. Select a data source.
    2. Click the **Add Entity** button and add a data type.
    3. Click the **Verify** button to verify your data store.
    4. Click **Save & Publish**.
  </Step>
</Steps>

### <a id="recordtype" />Create a record type

<Steps>
  <Step title="Open the ABBYYFlexiCapture application">
    In Appian Designer, open the ABBYYFlexiCapture application and click **New → Record Type**.
  </Step>

  <Step title="Name the record type">
    Complete the **Name** and **Plural Name** fields and click **Create & Edit**.
  </Step>

  <Step title="Configure the data and display">
    In the window that opens:

    1. In the **Data** section, select **Data Store Entity** and add your data store and your data type.
    2. Configure the display of your record list. For more information, see [Configure the record list](/flexi-capture/connectors/appian/appian-rt-layout-modify#recordlistmodify).
    3. Configure the display of the **Summary** tab. For more information, see [Configure the record view](/flexi-capture/connectors/appian/appian-rt-layout-modify#recordmodify).
  </Step>
</Steps>

### <a id="datastoreentity" />Create a constant of type "Data Store Entity"

This constant links your data store to your data type. When a new record is created, this link determines the record type of the record.

<Steps>
  <Step title="Create a new constant">
    In Appian Designer, open the ABBYYFlexiCapture application and click **New → Constant**. The constant is created from scratch and its default type is **Data Store Entity**.
  </Step>

  <Step title="Name the constant">
    Specify a name for your constant. The **Data Store** and **Data Type** fields are populated by the previously created objects.
  </Step>

  <Step title="Save the constant">
    Save the changes to the default AFC Rules and Constants folder or to any other folder of your choice.
  </Step>
</Steps>

### <a id="rulesedit" />Edit the rules

Once you have added the new record type and constant, modify the expression rules by adding conditions for the new record type.

<Steps>
  <Step title="Open the AFC_GetConstantDSEByRecordTypeName rule">
    1. In Appian Designer, open the ABBYYFlexiCapture application and select **Expression Rule** in the left-hand pane.
    2. Locate and click the `AFC_GetConstantDSEByRecordTypeName` rule to start editing it.
  </Step>

  <Step title="Add the condition for the new constant">
    In the code editor, replace `null` with the following `if` condition for the new record type and constant:

    ```text theme={null}
    if(ri!RecordTypeName == "Account Payable Records",
        cons!Constant_InvoiceProsessing_DSE,
        if(ri!RecordTypeName == "Credit Card Applications",
            cons!Constant_CreditApplication_DSE,
            if(ri!RecordTypeName == "New Records", /* In RecordTypeName, specify the name of the new record type in the plural. */
                cons!New_Constant, /* After cons!, specify the name of the constant you created earlier. */
                null
            )
        )
    )
    ```

    If an input `RecordTypeName` is the same as the name of a stored record type (in the plural), the `DataStoreEntity` constant that links the data store and the data type is returned.
  </Step>

  <Step title="Edit the AFC_GetDataTypeByRecordTypeName rule">
    1. In Appian Designer, open the ABBYYFlexiCapture application and select **Expression Rule** in the left-hand pane.
    2. Locate and click the `AFC_GetDataTypeByRecordTypeName` rule to start editing it.
    3. In the code editor, replace `null` with the following `if` condition for the new record type and the full name of the data type:

    ```text theme={null}
    if(ri!RecordTypeName == "Account Payable Records",
        'type!{urn:com:appian:types}Invoice_Header',
        if(ri!RecordTypeName == "Credit Card Applications",
            'type!{urn:com:appian:types}Credit_ApplicationMain',
            if(ri!RecordTypeName == "New Records", /* In RecordTypeName, specify the name of the new record type in the plural. */
                'type!{urn:com:appian:types}New_Data_Type', /* In the type! field, specify the full name of the data type and the namespace. */
                null
            )
        )
    )
    ```

    If an input `RecordTypeName` is the same as the name of a stored record type (in the plural), a string that contains the full name of the data type you created is returned. You can look up the namespace in the data type properties. To display the properties of a data type, open the data type in the ABBYYFlexiCapture application. Clicking the name of the data type in the top left corner opens the **Data Type Properties** window, where you can see the namespace.
  </Step>
</Steps>

### <a id="knowledgecenter" />Create a knowledge center

To store document images in Appian, create a knowledge center folder.

<Steps>
  <Step title="Open the ABBYYFlexiCapture application">
    In Appian Designer, open the ABBYYFlexiCapture application and click **New → Folder**.
  </Step>

  <Step title="Create the Knowledge Center folder">
    Select **Knowledge Center** as the type for your folder, complete the **Knowledge Center Name**, and click **Create**.
  </Step>
</Steps>

The ID of this folder is passed in the `Repository` field of the ABBYY FlexiCapture Connector for Appian export script settings. When data is exported from ABBYY FlexiCapture, image files are saved to this folder.

```xml theme={null}
<!--DMS repository name-->
    <Repository>5995</Repository>
```

You can [look up the ID of a knowledge center](/flexi-capture/connectors/appian/appian-fields-config#note-knowledgecenterid) on the **Runtime Data** tab of the **Knowledge Center Properties** dialog box.
