Skip to main content
Below is a list of functions that are available for creating custom scripts. To access object instances, use the commandArgs variable. All variables in this section are global and are visible across the entire program.

Function

Description

getCurrentField()

Returns a link to the field object that uses the current custom script.

getFieldByName(namesPath) (*)

Returns a link to the field for which the custom script has been opened.

Example:
[‘Document Section 1’, ‘Group[10]’,‘Field3’],
where [10] is the number of the instance of the repeating group.

  • namesPath is an array containing field and group names that form the path to the field or a link to a field object.

getFieldValue(namesPath) (*)

Returns:

  • a string for a TextField field;
  • a checkmark value for a Checkmark field;
  • a string array for a Checkmark Group field.

namesPath | fieldObject:

  • an array containing field and group names that form the path to the field or a link to a field object,
  • or a link to the field object.

setCurrentFieldValue(value, forced, onSaved)

Modifies the field value for which the custom script has been opened.

Parameters:

  • value – the field value.
  • forced – updates the field value and records new data. This parameter is optional.
    • false – the field value in the Document Definition will be updated only after the save() function has been called.
    • true – the field value in the Document Definition will be updated immediately.

      For a custom script, an update will occur regardless of the mode.
      By default, this parameter is set to false.
  • onSaved – callback function. Called if the forced parameter is set to true. This parameter is optional.

setFieldValue(namesPath | field, value, forced, onSaved) (*)

Modifies the field value.

Parameters:

  • namesPath | fieldObject:
    • an array containing field and group names that form the path to the field,
    • or a link to the field object.
  • value – value of the corresponding field.
  • forced – updates the field value and records new data. This parameter is optional.
    • false – the field value in the Document Definition will be updated only after the save() function has been called.
    • true – the field value in the Document Definition will be updated immediately.

      For a custom script, an update will occur regardless of the mode.
      By default, this parameter is set to false.
  • onSaved – A callback function. Called if the forced parameter is set to true. This parameter is optional.

save()

Closes the window where the custom script is executed and saves the changes.

cancel()

Closes the window where the custom script is executed without saving the changes.

(*) For some functions listed above, the path to the field is specified as an input parameter. It comprises the field name and the names of the parent elements (field group, section). For tables, repeating tables, and repeating groups, you need to specify the instance number starting at 0 (zero).

Example:
[‘Document Section 1’, ‘Group[10]’,‘Field3’],

where [10] is the number of the instance of the repeating group.

Function

Description

addEntity(entityInfo: {cacheName, columns, values}, onResult(newId))

Adds an entry to the data set.

Parameters:

  • entityInfo – an object:
    • cacheName – a name for the data set.
    • columns – names for the columns where data will be recorded. Array of strings.
    • values – the values for the corresponding columns. Array of strings.
  • onResult – a callback function that receives the ID of the record created in the data set.

editEntity(entityInfo: {cacheName, columns, values}, onResult())

Edits an entry in the database.

Parameters:

  • entityInfo – an object:
    • cacheName – a name for the data set.
    • columns – names for the columns where data will be recorded. Array of strings.
    • values – the values for the corresponding columns. Array of strings.
  • onResult – a callback function.

getDict({cacheName, filters: [{FieldName, FieldValue}], cursorPos, allowMultipleColumnResults}, onResult (param: { FieldName, FieldValue, BoldMask}[][]) )

Carries out a data set search for a specified value or for a part of it. Returns the matching strings in the following format:

[{FieldName
FieldValue
BoldMask}].

Parameters:

  • cacheName – the data set name.
  • filters – search parameters:
    • FieldName – the field name. Leave empty to search all fields.
    • FieldValue – the field value.
  • cursorPos – the position of the cursor in the entry field.
    • If a value was entered partially and the cursor is positioned after the typed symbols, they will be considered as a prefix for the value that is being searched for.
    • If the cursor is positioned before a partially typed word, those symbols will be considered as the ending of the value that is being searched for.

      For example, if, when searching for a company name, you type in “ADO” and the cursor is positioned after it, the value “AVOCADO” will be selected.
      If you type in “ADO” and the cursor is positioned in front of it, the value “ADONIS” will be selected.
  • allowMultipleColumnResults – Returns the values of the fields that have been found.
    The data set may contain entries for which one field name (FieldName) corresponds to multiple field values (FieldValue). For example, two or more variations of a company’s name may be specified in the CompanyName column.

    In this case:
    • true – returns and records all field values that satisfy the search conditions,
    • false – returns and records a single result that best fits the search conditions.
  • onResult – a callback function that returns a search result array. Each result is a single string from the data set, which is a string array. Each string comprises the field name, its value, and the BoldMask parameter.

    BoldMask – a string of ‘0’ and ‘1’ the same length as the value found during the search. ‘1’ represents a symbol from the found value that matches the corresponding symbol in the search field, and ‘0’ represents a symbol that does not.

If, for example, the following is present in a data set:

CompanyName: ABBYY

Let’s assume that a search is carried out for the symbols “ABB”.

Then, the following will be returned:

[

[

{

FieldName: ‘CompanyName’,

FieldValue: ‘ABBYY’,

BoldMask: ‘11100’

},

]

]

Note: The returned array can contain several values, including those that did not initially fit the search conditions. The search results in the array will be sorted by BoldMask parameter value in descending order (i.e. starting with strings that best match the search conditions).

getDictAll({cacheName, filters: {FieldName, FieldValue}}, }, onResult (param: { FieldName, FieldValue, BoldMask}[][]))

Carries out a database search for the entire value specified. Returns the values of all fields that have been found.

Parameters:

  • cacheName – the data set name.
  • Filters – an object array:
    • FieldName – the field name. In order to search on all fields, this should be left blank.
    • FieldValue – the field value.
  • onResult – a callback function that returns a search result array. Each result is a single string from the data set, which is itself a string array. Each string comprises the field name, its value, and the BoldMask parameter.

    BoldMask – a string of ‘0’ and ‘1’ the same length as the value found during the search. ‘1’ represents a symbol from the found value that matches the corresponding symbol in the search field, and ‘0’ represents a symbol that does not.


    If, for example, the following is present in a data set:

    CompanyName: ABBYY

    Let’s assume that a search is carried out for the symbols “ABB”.

    Then, the following will be returned:

[

[

{

FieldName: ‘CompanyName’,

FieldValue: ‘ABBYY’,

BoldMask: ‘11100’

},

]

]

Note: The returned array can contain several values, including those that did not initially fit the search conditions. The search results in the array will be sorted by BoldMask parameter value in descending order (i.e. starting with strings that best match the search conditions).

Sample database search script

Function

Description

selectRow(tablePath, rowNumber) (*)

Marks a table row as selected.

  • tablePath | fieldObject:
    • an array of field and group names that form the path to the table field,
    • or a link to a table object.
  • rowNumber – the number of the row to select, zero-based.

deselectRow(tablePath, rowNumber?) (*)

Removes selection from a table row.

  • tablePath | fieldObject:
    • an array of field and group names that form the path to the table field,
    • or a link to a table object.
  • rowNumber – the number of the row to deselect, zero-based, if omitted the selection is removed from all rows in the table.

scrollFormToField(namesPath) (*)

Scrolls the form editor to get the field into view.

  • namesPath | fieldObject:
    • an array of field and group names that form the path to the table field,
    • or a link to a table object.

getDomElementPosition(domId, onResult: (result?: {width, height, top, left, right, bottom}))

Gets the position of an element in the form editor window and returns the result of a callback function.

  • domId – element ID in DOM format.
  • onResult – a callback function that receives the object with the DOM coordinates of the element (width, height, top, left, right, bottom) relative to the top left corner of the browser window.

setStyles(styles, callback)

Adds CSS styles to the custom action frame window.

  • styles – an object with CSS property names and values.

    example:
    {
    display: ‘block’,
    position: ‘absolute’,
    top: ‘0px’,
    bottom: ‘0px’,
    left: ‘0px’,
    right: ‘0px’,
    width: ‘100%‘,
    height: ‘100%‘,
    border: ‘0’,
    overflow: ‘hidden’,
    ‘overflow-x’: ‘hidden’,
    ‘overflow-y’: ‘hidden’,
    ‘z-index’: ‘10000’
    }
  • callback – a callback function.

(*) For some functions listed above, the path to the field is specified as an input parameter. It comprises the field name and the names of the parent elements (field group, section). For tables, repeating tables, and repeating groups, you need to specify the instance number starting at zero.

Example:
[‘Document Section 1’, ‘Group[10]’,‘Field3’],

where [10] is the number of the instance of the repeating group.

Variables

Variable

Type

Description

commandArgs.params.document

Document

Stores an object copy of an open document. This can be used to get access to any error, field, or region for the current document.

commandArgs.params.currentField

(Picture | Checkmark | Checkmark Groups | FieldsGroup | Table | TextField)

Returns a link to a field object that reflects the state of the field at the time when the script is called. Part of the document specified above.

Note: If the field value was modified after the script was initialized, the changes will not be applied.

commandArgs.params.appPath

String

The server’s domain name.

commandArgs.params.coordinates

Object
[{X1,X2,Y1,Y2}]

The coordinates of the DOM element that called the custom script.

commandArgs.params.currentElementDomId

String

The ID of the DOM element that called the custom script.

Functions
FunctionDescription
commandArgs.events.addEventHandlerAdds an event handler in the global context of the custom script.
commandArgs.events.triggerHandlersTriggers an event in the global context of the custom script.
commandArgs.events.removeEventHandlerDeletes an event handler in the global context of the custom script.

Name

Type

Rights

Description

Fields

(Picture | Checkmark | Checkmark Groups | FieldsGroup | Table | TextField)[]

Read-only

Array of fields

HasTableLayout

Boolean

Read-only

Specifies if the field region is a table.

Caption

String

Read-only

Custom field name, caption

FieldType

Number

Read-only

Field type. Possible value:

4 – field group

Id

Number

Read-only

Field ID

IsReadOnly

Boolean

Read-only

Specifies whether editing of fields is disallowed.

IsVisible

Boolean

Read-only

Specifies whether the field is visible on the data form.

MaxRegions

Number

Read-only

Maximum number of field regions. If the value is -1, any number of regions is allowed.

Name

String

Read-only

Service name for the field.

NamePath

String[]

Read-only

Array of field and group names that form the path to the field.

NeedRecognize

Boolean

Read/write

Specifies whether to retrieve the field value from the region when the rules are checked again.

Regions

{
Id: number;
Status: number;
PageId: Number;
IsNew : Boolean;
Coordinates: Object
[{X1,X2,Y1,Y2}];
}[]

Read-only

Array of regions.

  • Id – region ID.
  • Status – status of the region.
    • 0 – region not superimposed (or region is deleted)
    • 1 – region is not recognized
    • 2 – the value from the region is substituted in the field
  • PageId – ID of the page on which the region is located.
  • IsNew – flag to indicate new regions.
  • Coordinates – coordinates of the region in the image.

Name

Type

Rights

Description

Fields

(Picture | Checkmark | Checkmark Groups | FieldsGroup | Table | TextField)[]

Read-only

Array of fields

Pageids

Number[]

Read-only

Identifiers of the pages on which the section is located.

IsFlexible

Boolean

Read-only

Specifies whether the section is flexible.

Caption

String

Read-only

Custom field name, caption

FieldType

Number

Read-only

Field type. Possible value:

6 – section

Id

Number

Read-only

Field ID

IsReadOnly

Boolean

Read-only

Specifies whether field editing is disallowed

IsVisible

Boolean

Read-only

Specifies whether the field is visible on the data form.

MaxRegions

Number

Read-only

Maximum number of field regions. If the value is -1, any number of regions is allowed.

Name

String

Read-only

Service name of the field

NamePath

String[]

Read-only

Array of field and group names that form the path to the field.

NeedRecognize

Boolean

Read/write

Specifies whether to retrieve the field value from the region when the rules are checked again.

Regions

{
Id: number;
Status: number;
PageId: Number;
IsNew : Boolean;
Coordinates: Object
[{X1,X2,Y1,Y2}];
}[]

Read-only

Array of regions.

  • Id – region ID.
  • Status – status of the region.
    • 0 – region not superimposed (or region is deleted)
    • 1 – region is not recognized
    • 2 – the value from the region is substituted in the field
  • PageId – ID of the page on which the region is located.
  • IsNew – flag to indicate new regions.
  • Coordinates – coordinates of the region in the image.

Name

Type

Rights

Description

Rows

{
Id: number;
RowNumber: number;
HasColorImage: boolean;
TableBlockID: number[];
Cells: (Picture | Checkmark | CheckmarkGroup | TextField)[];
}[]

Read-only

List of table rows.

The parameters of the object line in the table:

  • Id – row ID.
  • RowNumber – the sequence number of the row, counting from zero.
  • TableBlockId – identifiers of sections, tables, table blocks forming the path to the table block..
  • Cells – fields in table cells. Fields can be of the following types: picture, checkmark, checkmark group, text.

Caption

String

Read-only

Custom field name, caption

FieldType

Number

Read-only

Field type. Possible value:

7 – table

Id

Number

Read-only

Field ID

IsReadOnly

Boolean

Read-only

Specifies whether field editing is disallowed.

IsVisible

Boolean

Read-only

Specifies whether the field is visible on the data form.

MaxRegions

Number

Read-only

Specifies whether the field is visible on the data form -1, any number of regions is allowed.

Name

String

Read-only

Service name of the field.

NamePath

String[]

Read-only

Array of field and group names that form the path to the field.

NeedRecognize

Boolean

Read/write

Specifies whether to retrieve the field value from the region when the rules are checked again.

Regions

{
Id: number;
Status: number;
PageId: Number;
IsNew : Boolean;
Coordinates: Object
[{X1,X2,Y1,Y2}];
}[]

Read-only

Array of regions.

  • Id – region ID.
  • Status – status of the region.
    • 0 – region not superimposed (or region is deleted)
    • 1 – region is not recognized
    • 2 – the value from the region is substituted in the field
  • PageId – ID of the page on which the region is located.
  • IsNew – flag to indicate new regions.
  • Coordinates – coordinates of the region in the image.

Name

Type

Rights

Description

Flags

Number[]

Read/write

array of the same length as the field Value. Consists of 0 and 1.

0 – a character that is in Value in the same position as 0 in Flags, requires verification.

Suggests

String[]

Read-only

List of suggested field values

Value

String

Read/write

Field value

TextType

Number

Read-only

Type of text field. Possible value:

  • 0 – text field.
  • 1 – numeric field.
  • 2 – currency amount fields.
  • 3 – DateTime field.
  • 4 – Date field.
  • 5 – Time field.
  • 6 – Code field.

Caption

String

Read-only

Custom field name, caption

FieldType

Number

Read-only

Field type. Possible value:

0 – text field

Id

Number

Read-only

Field ID

IsReadOnly

Boolean

Read-only

Specifies whether field editing is disallowed.

IsVisible

Boolean

Read-only

Specifies whether the field is visible on the data form.

MaxRegions

Number

Read-only

Maximum number of field regions. If the value is -1, any number of regions is allowed.

Name

String

Read-only

Service name of the field.

NamePath

String[]

Read-only

Array of field and group names that form the path to the field.

NeedRecognize

Boolean

Read/write

Specifies whether to retrieve the field value from the region when the rules are checked again.

Regions

{
Id: number;
Status: number;
PageId: Number;
IsNew : Boolean;
Coordinates: Object
[{X1,X2,Y1,Y2}];
}[]

Read-only

Array of regions.

  • Id – region ID.
  • Status – status of the region.
    • 0 – region not superimposed (or region is deleted)
    • 1 – region is not recognized
    • 2 – the value from the region is substituted in the field
  • PageId – ID of the page on which the region is located.
  • IsNew – flag to indicate new regions.
  • Coordinates – coordinates of the region in the image.

IsVerified

Boolean

Read/write

Specifies whether the field has been verified.

NeedVerification

Boolean

Read-only

Specifies whether the field requires verification.

NeedDoubleVerification

Boolean

Read-only

Specifies whether the field requires double verification

IsSummary

Boolean

Read-only

Specifies whether the field is used in the formation of data summary on the data form.

Name

Type

Rights

Description

Value

Boolean

Read/write

Field value

Caption

String

Read-only

Custom field name, caption

FieldType

Number

Read-only

Field type. Possible value:

2 – checkmark

Id

Number

Read-only

Field ID

IsReadOnly

Boolean

Read-only

Specifies whether field editing is disallowed.

IsVisible

Boolean

Read-only

Specifies whether the field is visible on the data form.

MaxRegions

Number

Read-only

Maximum number of field regions. If the value is -1, any number of regions is allowed.

Name

String

Read-only

Service name of the field.

NamePath

String[]

Read-only

Array of field and group names that form the path to the field.

NeedRecognize

Boolean

Read/write

Specifies whether to retrieve the field value from the region when the rules are checked again.

Regions

{
Id: number;
Status: number;
PageId: Number;
IsNew : Boolean;
Coordinates: Object
[{X1,X2,Y1,Y2}];
}[]

Read-only

Array of regions.

  • Id – region ID.
  • Status – status of the region.
    • 0 – region not superimposed (or region is deleted)
    • 1 – region is not recognized
    • 2 – the value from the region is substituted in the field
  • PageId – ID of the page on which the region is located.
  • IsNew – flag to indicate new regions.
  • Coordinates – coordinates of the region in the image.

IsVerified

Boolean

Read/write

Specifies whether the field has been verified.

NeedVerification

Boolean

Read-only

Specifies whether the field requires verification.

NeedDoubleVerification

Boolean

Read-only

Specifies whether the field requires double verification.

IsSummary

Boolean

Read-only

Specifies whether the field is used in the formation of data summary on the data form.

Name

Type

Rights

Description

MaxSelectedCount

Number

Read-only

Maximum number of selected field values.

MinSelectedCount

Number

Read-only

Minimum number of selected field values.

Values

Number[]

Read/write

Field value. An array of record IDs that make up the list of possible field values (Variants).

Variants

{Id:number, Name:string}[]

Read-only

List of possible field values:

  • Id – record ID
  • Name – record name

Caption

String

Read-only

Custom field name, caption

FieldType

Number

Read-only

Field type. Possible value:

3 – checkmark group

Id

Number

Read-only

Field ID.

IsReadOnly

Boolean

Read-only

Specifies whether field editing is disallowed.

IsVisible

Boolean

Read-only

Specifies whether the field is visible on the data form.

MaxRegions

Number

Read-only

Maximum number of field regions. If the value is -1, any number of regions is allowed.

Name

String

Read-only

Service name of the field.

NamePath

String[]

Read-only

Array of field and group names that form the path to the field.

NeedRecognize

Boolean

Read/write

Specifies whether to retrieve the field value from the region when the rules are checked again.

Regions

{
Id: number;
Status: number;
PageId: Number;
IsNew : Boolean;
Coordinates: Object
[{X1,X2,Y1,Y2}];
}[]

Read-only

Array of regions.

  • Id – region ID.
  • Status – status of the region.
    • 0 – region not superimposed (region is deleted)
    • 1 – region is not recognized
    • 2 – the value from the region is substituted in the field
  • PageId – ID of the page on which the region is located.
  • IsNew – flag to indicate new regions.
  • Coordinates – coordinates of the region in the image.

IsVerified

Boolean

Read/write

Specifies whether the field has been verified.

NeedVerification

Boolean

Read-only

Specifies whether the field requires verification.

NeedDoubleVerification

Boolean

Read-only

Specifies whether the field requires double verification.

IsSummary

Boolean

Read-only

Specifies whether the field is used in the formation of data summary on the data form.

Name

Type

Rights

Description

Caption

String

Read-only

Custom field name, caption

FieldType

Number

Read-only

Field type. Possible value:

1 – picture

Id

Number

Read-only

Field ID.

IsReadOnly

Boolean

Read-only

Specifies whether field editing is disallowed.

IsVisible

Boolean

Read-only

Specifies whether the field is visible on the data form.

MaxRegions

Number

Read-only

Maximum number of field regions. If the value is -1, any number of regions is allowed.

Name

String

Read-only

Service name of the field.

NamePath

String[]

Read-only

Array of field and group names that form the path to the field.

Regions

{
Id: number;
Status: number;
PageId: Number;
IsNew : Boolean;
Coordinates: Object
[{X1,X2,Y1,Y2}];
}[]

Read-only

Array of regions.

  • Id – region ID.
  • Status – status of the region.
    • 0 – region not superimposed (or region is deleted)
    • 1 – region is not recognized
    • 2 – the value from the region is substituted in the field
  • PageId – ID of the page on which the region is located.
  • IsNew – flag to indicate new regions.
  • Coordinates – coordinates of the region in the image.

Name

Type

Rights

Description

Id

Number

Read-only

Field ID

Name

String

Read-only

Field name

Sections

Section[]

Read-only

Array of fields of Section type

FieldType

Number

Read-only

Field type.

Possible value:

8 – recurring section group.

Name

Type

Rights

Description

AssemblingErrors

{
DocumentNodeRef: number[][];
Description: string;
SectionName: string[]
}[]

Read-only

Build errors in the document where:

  • DocumentNodeRef – list of links as an array of field IDs to fields in the form
  • Description – error description
  • SectionName – list of sections involved in the error

BatchId

Number

Read-only

The package ID

Errors

{
DocumentNodeRef: number[][];
Severity: number;
Message: string;
RuleName: string;
}[]

Read-only

Errors in the document where:

  • DocumentNodeRef – list of links as an array of field IDs to fields in the form
  • Severity:
    • 1 – Error,
    • 0 – Warning
  • Message – error text
  • RuleName – the name of the rule that caused the error

Fields

(Section | SectionsGroup)[]

Read-only

List of sections/duplicate sections

Id

Number

Read-only

Document identifier

Index

Number

Read-only

Index of the document in the package

Pages

{
Id: number;
Modification: number;
HasColorImage: boolean;
ImageResolution: number;
KeyValue: string;
SectionTemplateId: number;
SectionTemplateName: string;
FlexibleInstanceId: number;
SectionTemplatePageNumber: number;
Comment: string;
ImageWidth: number;
ImageHeight: number;
}[]

Read-only

List of document pages containing the following:

  • Id – page ID
  • Modification – the revision number of the page
  • HasColorImage –specifies the color of the page
  • ImageResolution – image resolution
  • KeyValue – the value of the key field page
  • SectionTemplateId – ID section of the page
  • SectionTemplateName – page section name
  • SectionTemplatePageNumber – the page number in the section
  • Comment – review of the page
  • ImageWidth –width of the image page
  • ImageHeight – height of the page image

ProjectId

Number

Read-only

Project identifier

TaskId

Number

Read-only

Task ID

TemplateId

Number

Read-only

Definition ID of the document

TemplateName

String

Read-only

The name of the definitions document

TemplateVersion

Number

Read-only

Definition version of the document

Version

Number

Read-only

Document version