Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface RecordModel

RecordV2 data model.

A read only model can be created from any RecordV2 object using the asModel method. The model then provides direct access to the fields within the data. Fields may be accessed either by explicitly specifying the record and field occurrence or by specifying a key of the form:

recordName(recordIndex).fieldName(fieldIndex)

Indexes start from 0 and if omitted then 0 is assumed. The record name may also be omitted, in which case the first record definition is accessed. This form of addressing is useful when there is only one record definition.

So valid keys are:

Key Description
Address(4).AddressLine(3) The 4th AddressLine occurrence within the 5th Address record
Address.Name The first (or only) Name field within the first (or only) Address record
AddressLine(1) The 2nd AddressLine field within the first (or only) record
Name The first (or only) Name field within the first (or only) record

The RecordModel.recordCount and RecordModel.fieldCount methods are useful for determining the actual number of occurrences of variable multiplicity items.

since

6.0

Hierarchy

Index

Methods

asValue

  • Creates an immutable RecordV2 object generated from the model.

    Returns RecordV2

    a new immutable instance

fieldCount

  • fieldCount(recordName: string, recordIndex?: undefined | number, fieldName?: undefined | string): number
  • Returns the actual number of occurrences of a named field within a specified record.

    For all but variable fields this simply returns the schema defined number of occurrences of the field.

    Parameters

    • recordName: string

      the record name

    • Optional recordIndex: undefined | number

      the record index

    • Optional fieldName: undefined | string

      the field name

    Returns number

    the actual number of occurrences of the field

get

  • get(recordName: string, recordIndex: number, fieldName: string, fieldIndex?: undefined | number): string | null
  • get(recordName: string, fieldName: string, fieldIndex?: undefined | number): string | null
  • get(recordKey: string): string | null
  • Get a field value.

    This allows an item to be addressed using a key of the form recordName(recordIndex).fieldName(fieldIndex). Indexes may be omitted in which case 0 is assumed.

    Example:

    // Get field value with record & field names and indices
    const value = model.get("record", 0, "field", 0);
    
    // Get field value with key
    const value = model.get("Address.Name");

    Parameters

    • recordName: string

      the name of the record

    • recordIndex: number

      the index of the record

    • fieldName: string

      the name of the field

    • Optional fieldIndex: undefined | number

      the index of the field

    Returns string | null

    the field value

  • Parameters

    • recordName: string
    • fieldName: string
    • Optional fieldIndex: undefined | number

    Returns string | null

  • Parameters

    • recordKey: string

    Returns string | null

recordCount

  • recordCount(recordName: string): number
  • Returns the actual number of occurrences of a named record.

    If the record is not variable, this is the same as the defined number of occurrences in the schema

    Parameters

    • recordName: string

      the record name

    Returns number

    the actual number of occurrences of the record