Skip to main content

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.

Common patterns for writing a Condition activity script. Each sample reads from Context.Transaction.Documents and returns a boolean.

Checking for rule errors in a document

The script below returns true if at least one transaction document has rule errors, an undetermined document class, or suspicious symbols. Otherwise it returns false.
function hasRuleErrors() {
    for (var i = 0; i < Context.Transaction.Documents.length; i++) {
        var document = Context.Transaction.Documents[i];
        if (document.RuleErrors.length > 0 || document.IsUnknownSkill === true || document.HasSuspiciousSymbols === true)
            return true;
    }
    return false;
}
hasRuleErrors();

Checking whether manual review is required

The following script returns true — routing documents to manual review — if at least one transaction document has any of:
  • Rule errors
  • An uncertain document type
  • Suspicious fields or field characters (including nested children and repeating instances)
Otherwise it returns false and the documents continue to the export step.
function needManualReview() {
    for (var i = 0; i < Context.Transaction.Documents.length; i++) {
        var document = Context.Transaction.Documents[i];
        if (needManualReviewForDocument(document))
            return true;
    }
    return false;
}

function needManualReviewForDocument(document) {
    // Rule errors exist
    if (document.RuleErrors.length > 0)
        return true;
    // Document type is not confident
    if (!document.IsResultClassConfident)
        return true;
    // Some fields are suspicious
    for (var i = 0; i < document.Fields.length; i++) {
        var field = document.Fields[i];
        if (field.IsSuspicious || containSuspiciousFields(field))
            return true;
    }
    return false;
}

function containSuspiciousFields(field) {
    // Check all children for suspicious field
    if (field.Children) {
        for (var i = 0; i < field.Children.length; i++) {
            var childField = field.Children[i];
            if (childField.IsSuspicious || containSuspiciousFields(childField))
                return true;
        }
    }
    // Check all instances for suspicious field
    if (field.Instances) {
        for (var i = 0; i < field.Instances.length; i++) {
            var instanceField = field.Instances[i];
            if (instanceField.IsSuspicious || containSuspiciousFields(instanceField))
                return true;
        }
    }

    return false;
}
needManualReview();

Context

Global object exposing the current transaction, document, and processing.

Transaction

The current processing transaction and its documents.

Document

The document being processed by the Condition activity.

Field

Properties for reading a document field’s value, type, and OCR metadata.

RuleError

A Document skill validation rule error raised against a document.

Object model

Full JavaScript object reference for Condition activity scripts.