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

# Business rules automation

> Add scripted rules to a Document skill using JavaScript — configure readable and writable fields, reference table columns, and return validation results.

Add scripted rules to a Document skill to compare field values, validate conditions, or change field values programmatically.

To add an Advanced Script Rule, click **New rule** in the field properties and choose the script rule type. This page describes how to configure the rule and write its JavaScript.

## Set up an Advanced Script Rule

When setting up an **Advanced Script Rule**, specify which fields the script will reference.

### Configure fields

* In the **Fields** column, specify every field the script needs to read.
* In the **Changed by the rule** column, specify every field the script will edit.

<Note>
  If your script references a field that wasn't listed for reading, or writes to a field that wasn't listed for editing, the rule returns an access error:

  * `Attempt to read data from inaccessible field`
  * `Attempt to write data to read-only field`
</Note>

### Configure table columns

If your script references specific table columns, select those columns individually — not the entire table — when setting up the rule. All selected columns must belong to the same table.

For example, if the rule is applied to **Column 1** and **Column 2** of **New table**, select the following fields:

<Frame caption="Rule settings with Column 1 and Column 2 from 'New table' selected as processed fields">
  <img src="https://mintcdn.com/abbyy/hVcX1G4uYung9LOg/images/vantage/skill-designer/screen_docskill_rules_irulecontext_rulesettings.png?fit=max&auto=format&n=hVcX1G4uYung9LOg&q=85&s=29b21a8d94d90784fa463c1fdbc38688" alt="Rule settings dialog showing Column 1 and Column 2 selected from the New table" style={{ width: "60%" }} width="880" height="746" data-path="images/vantage/skill-designer/screen_docskill_rules_irulecontext_rulesettings.png" />
</Frame>

## Write the script

Switch to the script editor and write JavaScript that implements your rule.

Your script can read document fields, compute values, compare values, and update fields that were marked as writable during setup. Use the quick-edit buttons at the top of the script editor to insert common code snippets.

If the rule conditions aren't met, set [`Context.CheckSucceeded`](/vantage/documentation/skill-designer/document/rule-verification/context#checksucceeded) to `false`. This sends the document to manual review.

## Related topics

<CardGroup cols={3}>
  <Card title="Rule verification" icon="circle-check" href="/vantage/documentation/skill-designer/document/rule-verification/rule-verification">
    Use rules to validate, modify, or compute extracted field values in a Document skill.
  </Card>

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

  <Card title="Sample scripts" icon="code" href="/vantage/documentation/skill-designer/document/rule-verification/sample-scripts">
    Working script examples for common validation scenarios.
  </Card>
</CardGroup>
