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

# Script rule

> Create script rules in ABBYY FlexiCapture to run custom validation and normalization algorithms, with IRuleContext access to cached data sets.

## What it does

Rules based on scripts enable you to create complex custom algorithms for document validation and normalization.

The script rule is configured on the Rules tab of the  *(Administrator)* [Document Definition properties](/flexi-capture/templates/template-properties) *(Developer)* Document Definition properties.

## Parameters

| **Name** | **Type**                                                     | **Access**                     | **Description**         |
| -------- | ------------------------------------------------------------ | ------------------------------ | ----------------------- |
| Context  | [IRuleContext](/flexi-capture/appendix/scripts/irulecontext) | According to the rule settings | The context of the rule |

Procedures that you wish to use in more than one rule should be written to the global rule module, which can be accessed from the script editor. From the drop-down list on the toolbar of the script editor, select Rule Global Script Module. The global rule module can also be accessed from the Document Definition editor (**Document Definition → Script Modules →** Rule Script...).

Script rules can be used to access records of a cached data set. This can be useful if you need to create validation rules manually. Complete the following steps to access records in a cached data set:

1. Connect to the data set using the [IRuleContext](/flexi-capture/appendix/scripts/irulecontext).DataSet method.
2. Create a query using the [IDataSet](/flexi-capture/appendix/scripts/idataset).CreateQuery method.
3. Add one or more conditions using the [IDataSetQuery](/flexi-capture/appendix/scripts/idatasetquery).AddValue method.
4. Use the [IDataSet](/flexi-capture/appendix/scripts/idataset).GetRecords method to get data that satisfies the query. If you need to determine how many records satisfy the query, use the [IDataSet](/flexi-capture/appendix/scripts/idataset).GetRecordsCount method.
5. You can get records with specific index numbers using the [IRecordset](/flexi-capture/appendix/scripts/irecordset).GetRecord method.

If classes and methods of an [external assembly](/flexi-capture/appendix/scripts/user-assembly) are used in the script or global module, the assembly file must be attached on the .NET References  tab of the Document Definition properties.

## (Administrator) See also:

*(Administrator)*  [Script rule](/flexi-capture/templates/rule-script)
