メインコンテンツへスキップ

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.

Condition アクティビティ スクリプトを記述する際によく使われるパターンです。各サンプルは Context.Transaction.Documents を読み取り、ブール値を返します。

ドキュメント内のルールエラーの確認

次のスクリプトは、トランザクション内の少なくとも1つの Document にルールエラー、未確定のドキュメントクラス、または疑わしい記号がある場合に true を返し、それ以外の場合は 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();

手動確認が必要かどうかの確認

次のスクリプトは、トランザクション内の少なくとも1件のドキュメントに次のいずれかがある場合、trueを返してドキュメントを手動確認にルーティングします。
  • ルールエラー
  • 不確かな文書タイプ
  • 疑わしいfieldまたはfield文字 (入れ子の子要素および繰り返しインスタンスを含む)
それ以外の場合はfalseを返し、ドキュメントはエクスポート手順に進みます。
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) {
    // ルールエラーが存在する
    if (document.RuleErrors.length > 0)
        return true;
    // ドキュメントタイプが確実でない
    if (!document.IsResultClassConfident)
        return true;
    // 一部のfieldが疑わしい
    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) {
    // 疑わしい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;
        }
    }
    // 疑わしい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

現在のトランザクション、ドキュメント、処理にアクセスできるグローバル オブジェクト。

Transaction

現在の処理トランザクションとそれに含まれるドキュメント。

Document

Condition アクティビティ で処理されるドキュメント。

Field

ドキュメント field の値、型、OCR メタデータを読み取るためのプロパティ。

RuleError

ドキュメントに対して発生する Document skill の検証ルール エラー。

オブジェクト モデル

Condition アクティビティ スクリプト向けの完全な JavaScript オブジェクト リファレンス。