Skip to main content
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. We want the skill to select which Extraction Rules activity will process a particular document based on the document class. We have already set up the appropriate processing flow and now we have to specify the condition for choosing the correct workflow branch.
  1. Click the IF activity in the workflow.
  2. Look at the Case Conditions section of the Activity Properties pane. Click the settings icon next to the “Sick Note DE” activity.
  3. The IF activity is set up using a script. It will select the next activity for a document depending on the document class determined by the Classify By Text and Image activity. The classification result is recorded to the “Layout” field. Possible values of this field 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:
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;
  1. Click Save.
  2. Click the settings icon next to the “Sick Note BE-NL” activity and paste the following script in the script editor that will open:
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;
  1. Click Save.
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. If you want to try and extract data from a document even if its class could not be determined, you may create a special Extraction Rules activity for documents with no class or forward them to one of the existing Extraction Rules activities.