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

# Context

> The Context global object — properties and methods for accessing the document, fields, catalog records, and skill parameters during rule execution.

`Context` is a global object that provides access to the document being processed, its fields, and the parameters of the enclosing transaction. Set [`CheckSucceeded`](#checksucceeded) to indicate whether the rule passed.

## Usage

A rule reads fields through `Context`, checks them, and reports the result by setting [`CheckSucceeded`](#checksucceeded) and [`ErrorMessage`](#errormessage). For example, fail the rule with a custom message when the `Total` field is missing or empty:

```javascript theme={null}
var field = Context.GetField("Total");

if (!field || !field.Value) {
  Context.CheckSucceeded = false;
  Context.ErrorMessage = "Total field is empty";
}
```

For more patterns — numeric comparisons, conditional requirements, and table validation — see [Sample scripts](/vantage/documentation/skill-designer/document/rule-verification/sample-scripts).

## Properties

### CheckSucceeded

**Type:** `bool` — **Access:** Read-write

Indicates whether the rule condition is fulfilled. Defaults to `true`. Set it to `false` if the condition is not met. In that case, the default error message shown to the operator is `Error in the rule <rule_name>: <field_name>`. To customize the message, set the `ErrorMessage` property.

<Note>
  An error is generated only when your script sets `CheckSucceeded` to `false`. If the script doesn't set it explicitly, no error is displayed — even if the rule conditions aren't met.
</Note>

### CurrentField

**Type:** [Field](/vantage/documentation/skill-designer/document/rule-verification/field) — **Access:** Read-only

The field checked by the rule. For repeating fields in repeating rules, this is the specific instance being checked by the current call. Returns `null` if the rule references the document as a whole.

### Document

**Type:** [Document](/vantage/documentation/skill-designer/document/rule-verification/document) — **Access:** Read-only

The document for which the rule runs.

### ErrorMessage

**Type:** `string` — **Access:** Read-write

Custom message displayed when the script sets `CheckSucceeded` to `false`. If unset, the default message is `Error in the rule <rule_name>: <field_name>`.

### Transaction

**Type:** [Transaction](/vantage/documentation/skill-designer/document/rule-verification/transaction) — **Access:** Read-only

The current transaction.

## Methods

<Note>
  A script can only read fields listed for reading and write fields listed as editable when the rule is set up. Referencing any other field fails the rule with an access error (`Attempt to read data from inaccessible field` or `Attempt to write data to read-only field`). See [Business rules automation](/vantage/documentation/skill-designer/document/rule-verification/business-rules-automation).
</Note>

### GetField

```javascript theme={null}
Field GetField(string fieldName);
```

Gets a [`Field`](/vantage/documentation/skill-designer/document/rule-verification/field) by name or identifier. Returns `null` if no field with that name exists.

Use the [full path](/vantage/documentation/skill-designer/document/rule-verification/field#fullname) to address fields inside a group — for example, `BusinessUnit/Address`.

When used in a repeating rule, `GetField` sequentially returns each processed field instance. Otherwise, it returns the first instance of a repeating field.

<Warning>
  Pass the field name as a string literal, not a variable. The script preprocessor replaces the literal name with the field's identifier before execution — variables aren't processed.
</Warning>

### GetFields

```javascript theme={null}
Field[] GetFields(string fieldName);
```

Returns all [`Field`](/vantage/documentation/skill-designer/document/rule-verification/field) objects with the specified name — useful for iterating over every instance of a repeating field, including every cell in a table column. Returns `null` if no field with that name exists.

<Warning>
  Same preprocessor constraint as `GetField`: pass a string literal, not a variable.
</Warning>

### GetCatalogRecord

```javascript theme={null}
Record GetCatalogRecord(string catalogId, string externalId);
```

Gets a [`Record`](/vantage/documentation/skill-designer/document/rule-verification/record) from a data catalog (external database). Use this method to compare document field values against catalog field values.

<Note>
  Available only if the catalog has a record identifier configured (for example, a vendor identifier).
</Note>

### SkillParameter

```javascript theme={null}
SkillParameter SkillParameter(string ParameterName);
```

Gets a [`SkillParameter`](/vantage/documentation/skill-designer/document/rule-verification/skill-parameter) by name. Read its value from the returned object's `Value` property — for example, `Context.SkillParameter("Threshold").Value`.

<Note>
  Available only if the Document skill has at least one parameter.
</Note>

## Related topics

<CardGroup cols={3}>
  <Card title="Object model" icon="diagram-project" href="/vantage/documentation/skill-designer/document/rule-verification/object-model">
    Full JavaScript object reference for use in Advanced Script Rules.
  </Card>

  <Card title="Business rules automation" icon="code" href="/vantage/documentation/skill-designer/document/rule-verification/business-rules-automation">
    Add scripted rules to a Document skill, configure readable and writable fields, and reference table columns.
  </Card>

  <Card title="Field" icon="font" href="/vantage/documentation/skill-designer/document/rule-verification/field">
    The Field object — inspect and modify a document field during rule execution.
  </Card>

  <Card title="Sample scripts" icon="code" href="/vantage/documentation/skill-designer/document/rule-verification/sample-scripts">
    Working JavaScript samples for common Advanced Script Rule scenarios.
  </Card>
</CardGroup>
