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

# Custom fields

> Extract custom invoice fields in ABBYY FlexiCapture by developing additional or vendor-specific FlexiLayouts or training a Document Definition.

FlexiCapture for Invoices lets you extract invoice fields for which no predefined data types are available, and change the way any field is extracted.

There are several ways to do this:

| Method                                            | Description                                                                                                                                                                              |
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Develop an additional FlexiLayout                 | An additional FlexiLayout lets you extract fields for which no predefined data types are available and change the way standard fields are extracted from any vendor's invoices.          |
| Develop a FlexiLayout for a specific vendor       | Vendor-specific FlexiLayouts let you extract fields for which no predefined data types are available and change the way standard fields are extracted from a specific vendor's invoices. |
| Train a Document Definition for a specific vendor | Creating a Document Definition for a specific vendor lets you train the program to extract fields from that vendor's invoices.                                                           |

You can use any one of these solutions, or combine them. For example, you can add a new field to an additional Document Definition that is applied to invoices from all vendors, train the program to recognize the new field on invoices from some vendors, and create a FlexiLayout variant for the other vendors.

For more information about how multiple FlexiLayouts are applied, see [How results from different FlexiLayouts are merged](/flexi-capture/invoice-reader/ir-mechanism).

## Create an additional FlexiLayout

Any FlexiLayout created in ABBYY FlexiLayout Studio can be used as an additional FlexiLayout in FlexiCapture for Invoices.

To extract a new type of field, create a new block with a unique name in a FlexiLayout and define the logic for finding it on images. When this FlexiLayout is added to a Document Definition, a new field with the same name as the new block in the FlexiLayout is created.

If the name of the block in the additional FlexiLayout is the same as the name of a standard field in the Document Definition, the additional FlexiLayout is used to extract the block.

To add a FlexiLayout to a Document Definition:

<Steps>
  <Step title="Open the Document Definitions dialog box">
    Click **Document Definitions...** on the **Project** menu.
  </Step>

  <Step title="Edit the Document Definition">
    In the dialog box that opens, select a **Document Definition** and click the **Edit...** button.
  </Step>

  <Step title="Open the Document Definition properties">
    Click **Document Definition Properties...** on the **Document Definition** menu.
  </Step>

  <Step title="Open the FlexiLayout tab">
    Click the **FlexiLayout** tab in the dialog box that opens.
  </Step>

  <Step title="Load the FlexiLayout">
    Click the **Load...** button in the **Additional FlexiLayout** options group and specify the path to the FlexiLayout file in the dialog box that opens (FlexiLayout files have the `.afl` extension).
  </Step>
</Steps>

ABBYY FlexiLayout Studio has several features for developing additional FlexiLayouts for invoices:

* You can find the IDs of the vendor and the business unit of an invoice and reference a data set in a Document Definition.
* You can specify the positions of elements relative to fields that may be detected when the main FlexiLayout is applied.
* You can parametrize the FlexiLayout using an XML file, which lets you store and edit complex lists of keywords and other FlexiLayout parameters without editing the FlexiLayout or the Document Definition.

For more information about the special features of ABBYY FlexiLayout Studio, see [Special features of ABBYY FlexiLayout Studio for creating additional FlexiLayouts](/flexi-capture/invoice-reader/ir-fls-special-facilities).

## Develop a FlexiLayout variant for a specific vendor

FlexiCapture for Invoices lets you use a separate FlexiLayout variant when processing invoices from a specific vendor. This additional FlexiLayout variant can be created automatically using training. If you are not satisfied with the variant, you can open it in ABBYY FlexiLayout Studio and manually change the field search algorithm.

### Enable and apply training

To enable the training feature in the Document Definition editor:

<Steps>
  <Step title="Open the Document Definition settings">
    Open **Document Definition Properties... → Document Definition Settings**.
  </Step>

  <Step title="Edit the additional fields and features">
    Click **Edit...** in the **Additional Fields and Features** group.
  </Step>

  <Step title="Enable training">
    Select **Training during invoice processing**.
  </Step>
</Steps>

You can train both existing fields and new ones. To apply the training feature:

<Steps>
  <Step title="Add an invoice">
    Add at least one invoice from the vendor to a batch.
  </Step>

  <Step title="Recognize it">
    Recognize the invoice.
  </Step>

  <Step title="Verify the vendor">
    Make sure the program determines the vendor correctly. If it does not, specify the right vendor manually.
  </Step>

  <Step title="Mark the field">
    Change the location of the field you want to train, or designate its region.
  </Step>

  <Step title="Train">
    Select the invoice and click **Train**. A **Training batch** is created.
  </Step>
</Steps>

<Note>
  Training begins after the first recognized invoice, but for better quality you need to provide the program with at least three sample images that contain this field.
</Note>

### Review and edit the training batch

An Administrator can review and modify the **Training batch** created as a result of Operator-driven training:

<Steps>
  <Step title="Open the training batch view">
    Click the <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/DocVariantsButton.png?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=83762cc174be930546e05af50a27f2be" alt="" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="23" height="23" data-path="images/flexi-capture/DocVariantsButton.png" /> **Open Field Extraction Training Batches** button on the toolbar to switch to the training batch view. The training batch contains sample batches from a specific vendor, which are used to train the FlexiLayout for this vendor.

    Then decide whether to use automatic training or edit the FlexiLayout variant manually:

    * For automatic training, add a few more sample invoices to the batch (at least three recommended) and specify the field regions. For more information, see [Training done by project administrators](/flexi-capture/invoice-reader/ir-training-doc-variants).
    * To edit the FlexiLayout variant manually, continue with the following steps.
  </Step>

  <Step title="Export the trained FlexiLayout">
    Export a FlexiLayout variant that contains images from the training batch and the FlexiLayout created during training to ABBYY FlexiLayout Studio. Either:

    * Click **Training → Export Trained FlexiLayout...** on the **Project** menu, or
    * Right-click the batch and select **Export Trained FlexiLayout...** from the shortcut menu.
  </Step>

  <Step title="Open the project in FlexiLayout Studio">
    Open the project you created in ABBYY FlexiLayout Studio.

    Blocks in the FlexiLayout correspond to fields in the Document Definition. All blocks involved in the training have the <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/FLS_ButtonTrained.png?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=1f55703da46412d0aee14efdf5a1cc05" alt="" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="30" height="30" data-path="images/flexi-capture/FLS_ButtonTrained.png" /> icon, which indicates that the algorithm for extracting a block has been generated automatically.

    Making changes to the FlexiLayout causes the program to consider these blocks to have been created manually. When the Document Definition is applied, the program has to choose the FlexiLayout from which it picks the field's region, and manually created blocks always have higher priority. For more information, see [How results from different FlexiLayouts are merged](/flexi-capture/invoice-reader/ir-mechanism).

    Because of this, remove the blocks whose search algorithm you do not want to change. These blocks are still present in the main FlexiLayout, so they are still extracted when the Document Definition is applied. For example, to specify a custom algorithm for the **InvoiceDate** and **MyField** blocks, leave these blocks in the FlexiLayout and delete all the others.

    <Note>
      You cannot create new fields in a Document Definition for a specific vendor by simply adding a new block to a FlexiLayout. Blocks in a FlexiLayout variant that do not correspond to a field in a Document Definition cause an error when processing invoices from the vendor. To extract a new field from invoices from a specific vendor, create the field in the Document Definition first (see [Train a Document Definition for a specific vendor](#train-a-document-definition-for-a-specific-vendor)).
    </Note>
  </Step>

  <Step title="Specify the search algorithm">
    Specify the search algorithm used to find the blocks using the standard tools of ABBYY FlexiLayout Studio.
  </Step>

  <Step title="Export to an .afl file">
    Export the FlexiLayout variant to an `.afl` file by clicking **Export...** on the **File** menu.
  </Step>

  <Step title="Import the FlexiLayout">
    In FlexiCapture, click the <img src="https://mintcdn.com/abbyy/IFr-A2MDVJd80FDs/images/flexi-capture/DocVariantsButton.png?fit=max&auto=format&n=IFr-A2MDVJd80FDs&q=85&s=83762cc174be930546e05af50a27f2be" alt="" style={{display:"inline-block",verticalAlign:"middle",margin:0}} width="23" height="23" data-path="images/flexi-capture/DocVariantsButton.png" /> **Open Field Extraction Training Batches** button on the toolbar to switch to the testing batch view. Then import the FlexiLayout. Either:

    * Click **Training → Import FlexiLayout...** on the **Project** menu, or
    * Right-click the batch and click **Import FlexiLayout...** on the shortcut menu.

    Specify the path to the `.afl` file you created in the previous step.
  </Step>

  <Step title="Recognize sample invoices">
    Recognize sample invoices from the vendor. The operation's log contains messages about which field regions were selected from the FlexiLayout variant for the vendor.
  </Step>

  <Step title="Check the results">
    Check the processed documents by opening them in an editor.
  </Step>
</Steps>

## Train a Document Definition for a specific vendor

To create a new field:

<Steps>
  <Step title="Create the field">
    In the Document Definition editor, select **Edit → Create Field** (or right-click in the list of fields). Select a field type.
  </Step>

  <Step title="Name the field">
    In the **Properties** dialog box, enter a name for the additional field and select the **Can have region** option.
  </Step>
</Steps>

<Note>
  For detailed instructions on configuring fields of various types, see [Document Definition fields](/flexi-capture/templates/fields).
</Note>

A new field with the name you specified appears on the data form and in the list of fields.

Now train the program to capture data from this field. Training is done separately for each vendor. For more information, see [Training during invoice capture](/flexi-capture/invoice-reader/ir-operator-training).
