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

# IF activity

> Branch a document processing flow on classification results or field values — choose the next activity using a Case Condition and an Else Condition.

The IF activity lets you create workflow branches and use classification results and field values to select the next activity.

A good example of when an IF activity needs to be used is a flow that contains a classify activities and different extraction activities for documents with different classes. In this case, the If activity acts as a condition for the following: if the document is classified into type A, it will be processed using extraction activity 1, if the document is classified into class B, extraction activity 2 will be used.

To set up an IF activity:

<Steps>
  <Step title="Add the activity to the flow">
    Add an IF activity to the document processing flow.
  </Step>

  <Step title="Configure Case Condition">
    In **Case Condition**, select an activity or the end of the flow as a branch for the flow. Click the settings icon next to the selected condition and use the dialog that opens to write a script that describes the branch condition, then click **Save**.
  </Step>

  <Step title="Configure Else Condition">
    In **Else Condition**, select an activity or the end of the flow as the other branch. If the Case Condition is true, the previous branch is selected in the flow; otherwise, the branch specified in Else Condition is selected.
  </Step>
</Steps>

You can use the sample code below to create your own script:

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

<Warning>
  The CurrentDocument property is deprecated. Always points to the first document in a transaction. To get all transaction documents, use `Context.Transaction.Documents`.
</Warning>
