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:
Add the activity to the flow
Add an IF activity to the document processing flow.
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.
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.
You can use the sample code below to create your own script:
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();
The CurrentDocument property is deprecated. Always points to the first document in a transaction. To get all transaction documents, use Context.Transaction.Documents.