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

# Step 4. Configure the IF activity

> Set up conditional routing based on document classification results using script-based case conditions.

<Tip>
  Instead of using the IF activity, you can create a workflow item containing two Extraction Rules activities and select the "Layout" field as a source field so that its values serve as conditions for choosing which activity will be applied to each document.
</Tip>

The IF activity routes documents to the correct Extraction Rules activity based on classification result. The processing flow is in place — now define the condition for each branch.

<Steps>
  <Step title="Select the IF activity">
    Click the `IF` activity in the workflow.
  </Step>

  <Step title="Open the Sick Note DE case condition">
    In the **Case Conditions** section of the **Activity Properties** pane, click the settings icon next to the "Sick Note DE" activity.
  </Step>

  <Step title="Add the script for the DE branch">
    The `IF` activity uses a script to select the next activity based on the document class determined by the `Classify By Text and Image` activity. The classification result is recorded to the "Layout" field, whose possible values are the names of the classes created in the `Classify By Text and Image` activity.

    Paste the following script to the script editor to forward all documents of class "DE" to the "Sick Note DE" activity:

    ```javascript theme={null}
    for (var i = 0; i < Context.Transaction.Documents[0].Fields.length; i++)
    {
        if (Context.Transaction.Documents[0].Fields[i].Name === 'Layout' && Context.Transaction.Documents[0].Fields[i].Value === 'DE')
        {
            return true;
        }
    }
    return false;
    ```

    Click **Save**.
  </Step>

  <Step title="Add the script for the BE branch">
    Click the settings icon next to the "Sick Note BE-NL" activity and paste the following script in the script editor:

    ```javascript theme={null}
    for (var i = 0; i < Context.Transaction.Documents[0].Fields.length; i++)
    {
        if (Context.Transaction.Documents[0].Fields[i].Name === 'Layout' && Context.Transaction.Documents[0].Fields[i].Value === 'BE')
        {
            return true;
        }
    }
    return false;
    ```

    Click **Save**.
  </Step>
</Steps>

If the document is of an unknown class or if the "Layout" field doesn't exist (which means the document couldn't be processed by the classification activity), it will be forwarded directly to `Fast Learning`.

<Tip>
  If you want to try and extract data from a document even if its class could not be determined, you can create a special `Extraction Rules` activity for documents with no class or forward them to one of the existing `Extraction Rules` activities.
</Tip>

## What's next

<CardGroup cols={2}>
  <Card title="Step 5. Configure the Fast Learning activity" icon="arrow-right" href="/vantage/documentation/advanced-designer/tutorial/tutorial-step-5">
    Define the data form, label fields on German sick notes, and train the Fast Learning activity.
  </Card>

  <Card title="Tutorial overview" icon="circle-info" href="/vantage/documentation/advanced-designer/tutorial/tutorial">
    Back to the tutorial introduction.
  </Card>
</CardGroup>
