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

# Multiple Extraction Rules in a single activity

> Create a single processing flow item with several independent Extraction Rules activities and activity choice conditions for document variants.

A document set may include document variants with different layouts, e.g. statements from different banks or invoices issued by different companies.

Advanced Designer allows you to create a single processing flow item that contains several independent Extraction Rules activities and activity choice conditions. The choice of activity is determined by the value of the field which contains data that is used to distinguish among the document variants. This is typically a field containing classification results, but generally this can be any field that has been filled by any preceding activity. You configure branching conditions for activities in the set by mapping the field values to the activities. You may also select an action for all field values not specified in the mapping table: you can either assign them an Extraction Rules activity from the set or choose to skip this processing step.

## Use cases

This method can be useful in the following cases:

| Case                                                                                                                                                                                                                                            | How document variants are distinguished                                                                  | Sample mapping                                                                                                               |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| You have classified your documents by layout or by a certain parameter, e.g. the year the document was issued. You need to configure separate extraction rules for some of the document classes.                                                | Based on the results of classification by text and image or some document parameter extracted to a field | Field value = A : Extraction Rules A / Field value = B : Extraction Rules B / All other field values : Skip this step        |
| You have classified your documents by company and need to configure separate extraction rules for documents from each company in your catalog. You want to use a general Extraction Rules activity for all companies not listed in the catalog. | Based on the results of classification by company                                                        | CompanyID = 1 : Extraction Rules 1 / CompanyID = 2 : Extraction Rules 2 / ... / Other company IDs : General Extraction Rules |

The activities merged into one processing flow item have the same set of output fields. If you change the state of a field for one activity, it will be consistently changed for all other activities in the set.

If you delete the item from the document processing flow, all activities inside it are also deleted and cannot be restored.

## Create a new set of activities

<Steps>
  <Step title="Add a regular Extraction Rules activity">
    Add a regular Extraction Rules activity to the document processing flow.
  </Step>

  <Step title="Add a second activity">
    Click **Add activity and set condition for its use** on the **Activity Properties** pane.
  </Step>

  <Step title="Name the new activity">
    Specify the name of a new activity and click **Add**.
  </Step>

  <Step title="Add more activities as needed">
    Go to the **Activities** tab on the **Activity Properties** pane and add as many activities as needed by clicking **Add**.
  </Step>
</Steps>

<Tip>
  You can set branching condition for each activity in the **Add Extraction Rules Activity** dialog or configure all activities later.
</Tip>

## Configure activities and branching conditions

Select the activity in the processing flow and open the **Activities** tab of the **Activity Properties** pane. You will see a list of activities added to the item. The error icon indicates that an activity has errors or is not configured. The alert icon indicates that the branching condition for an activity is not set.

<Steps>
  <Step title="Open the Conditions dialog">
    Click **Conditions** at the bottom of the **Activity Properties** pane.
  </Step>

  <Step title="Specify the field">
    In the dialog that opens, specify the field whose values will determine the choice of an Extraction Rules activity.

    <Note>
      Changing a field to get values from will reset the mapping.
    </Note>
  </Step>

  <Step title="Map field values to activities">
    All available Extraction Rules activities are listed in the mapping table. Map the field values to the activities.
  </Step>

  <Step title="Set an action for unlisted values">
    Select an action for the values not listed in the mapping table. You can select either to use one of the activities added to the set or to skip this processing step.
  </Step>

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

Each activity should be configured in the **Activity Editor** the same way as a regular Extraction Rules activity. For more information, see [Extraction Rules activity description](/vantage/documentation/advanced-designer/activities/extraction-rules). To open the **Activity Editor** for a certain activity, click on the activity name in the list of activities. If the activity is selected in the list, you can also open the editor by clicking the **Activity Editor** button at the bottom of the **Activity Properties** pane.

You can rename and delete an activity via the menu that opens when you click the more icon to the right of the activity name. By selecting the **Use as Separate Activity** option in this menu, you can detach an activity from the set. It will be recreated as a separate item of the document processing flow. All configured extraction rules will be preserved.

## Merge existing activities

You can also merge existing activities by dragging and dropping a regular Extraction Rules activity on another such activity or on a set of activities. After dropping the activity, you'll have to open the **Conditions** dialog to set the branching condition for the newly added activity.

The list of fields enabled for the dropped activity will be harmonized with the list of fields enabled for the item with which it is merged. All extraction rules configured in the activities will be preserved.

## Split an activity

Having created the set of Extraction Rules activities, you may decide to add other activities to the branches of the document processing flow. For example, you may want to replace one of the Extraction Rules activities with a Fast Learning activity or add a Script activity to a certain branch of the workflow. In this case you can split the set of activities into a bunch of regular Extraction Rules activities preceded by an IF activity. To do so, select the activity in the workflow and click the split icon in the pop-up window.

All configured extraction rules will be preserved. You will have to configure the case conditions for each activity manually.
