Skip to main content
A newer version of this page is available. .

FieldCollection Class

A collection of the Field objects.

Declaration

export class FieldCollection extends Collection<Field>

Inherited Members

Inheritance

Collection<T>
FieldCollection

Methods

create(position) Method

Creates a new field.

Declaration

create(
    position: number,
    code?: string
): Field

Parameters

Name Type Description
position number

A position in the document.

code string

A field code.

Returns

Type Description
Field

The newly created field object.

Remarks

The newly created field has no result value until the field is updated. To update the field, use the UI or call the update or updateAllFields method.

richEdit.document.fields.create(500,'TIME').update();

Supported Fields

Field Name Functionality
DATE Inserts the current date and time.
DOCVARIABLE Enables you to programmatically insert complex content when this field is updated.
HYPERLINK Enables you to navigate to another location or to a bookmark.
MERGEFIELD Retrieves a value from the bound data source. See also the createMergeField(position, name) property description.
NUMPAGES Inserts the total number of pages.
PAGE Inserts the number of the page that contains the field.
TIME Inserts the current time.
TOC Inserts the Table of Contents.
SEQ Inserts the number of the figure/table/equations.
TC Inserts the alternate entry for the Table of Contents
PAGEREF Inserts a number of the page that stores the specified bookmark for a cross-reference.
See Also

createMergeField(position, name) Method

Creates a new merge field.

Declaration

createMergeField(
    position: number,
    name: string
): Field

Parameters

Name Type Description
position number

A position in the document.

name string

The name of a data source column.

Returns

Type Description
Field

The newly created field.

Remarks

The newly created field has no result value until the field is updated. To update the field, use the UI or call the update or updateAllFields method.

richEdit.document.fields.createMergeField(520, 'City').update();
See Also

find(position) Method

Returns a list of fields that traverse the specified position or interval.

Declaration

find(
    position: number | IInterval
): Field[]

Parameters

Name Type Description
position number | IInterval

A document position or interval.

Returns

Type Description
Field[]

A list of fields.

showAllFieldCodes Method

Displays field codes in place of the fields in the document.

Declaration

showAllFieldCodes(
    doInAllSubDocuments?: boolean
): void

Parameters

Name Type Description
doInAllSubDocuments boolean

true, to display field codes in all sub-documents, false, to display field codes in the current sub-document only.

showAllFieldResults Method

Displays field results in place of the fields in the document.

Declaration

showAllFieldResults(
    doInAllSubDocuments?: boolean
): void

Parameters

Name Type Description
doInAllSubDocuments boolean

true, to display field results in all sub-documents, false, to display field results in the current sub-document only.

updateAllFields Method

Updates and displays all field results.

Declaration

updateAllFields(
    callback?: () => void,
    options?: UpdateFieldsOptions
): boolean

Parameters

Name Type Description
callback () => void

A function that is called after fields are updated.

options UpdateFieldsOptions

An object that contains update options.

Returns

Type Description
boolean

true, if the field has been updated successfully; otherwise, false.

Remarks

richEdit.document.fields.updateAllFields();
See Also