Cloud Software Group, Inc. EBX®
Documentation > Developer Guide > EBX® Script > API
Navigation mode Documentation > Developer Guide > EBX® Script > API

# Unit core.complex

Script unit that provides methods to create and update complex values.

Methods
foreignKeyOf<foreignKeyType>(): foreignKeyType Create an instance of a foreign key type.
formatPrimaryKey(primaryKey: primaryKeyType): string Returns the internal tableRef String representation of a primary key.
of<complexType>(): complexType Create an instance of a complex type.
parsePrimaryKey<primaryKeyType>(value: string): primaryKeyType Parses a string to a primary key.
primaryKeyOf<primaryKeyType>(): primaryKeyType Create an instance of a primary key type.

## foreignKeyOf

foreignKeyOf<foreignKeyType>(): foreignKeyType

Create an instance of a foreign key type.

Note: A foreign key field contains a primary key on the referenced table.

This method is equivalent to the method complex.primaryKeyOf. The method complex.primaryKeyOf should be preferred

Example:

    uses core.complex as complex;

    export function getValue(): typeof _ebx.record.Supervisor
    begin
      var foreignKey := complex.foreignKeyOf<typeof _ebx.record.Supervisor>();
      foreignKey.Id := 435;
      return foreignKey;
    end

Function Types :

primaryKeyType: the primary key type. Can be the type of a foreign key or a an expression foreignKeyOf. Is mandatory.

Return :

the new foreign key object. Is always mutable.

Can be used in: Script tasks, Table triggers, Function fields

## formatPrimaryKey

formatPrimaryKey(primaryKey: primaryKeyType): string

Returns the internal tableRef String representation of a primary key.

Function Types :

string: the primary key internal representation.

Parameters :

primaryKey: the primary key

Return :

the new mutable primary key object if the string is parsable, otherwise null.

Can be used in: Script tasks, Table triggers, Function fields

## of

of<complexType>(): complexType

Create an instance of a complex type.

Example:

    uses core.complex as complex;

    export function getValue(): typeof _ebx.record.OfficeAddress
    begin
      var value := complex.of<typeof _ebx.record.OfficeAddress>();
      value.Street := '4323 Broadway';
      value.City := 'New York';
      value.State := 'NY';
      value.Zip := '10019';
      value.Country := 'USA';
      return value;
    end

Function Types :

complexType: the object type. Is mandatory. Should be an expression typeof identifier.

Return :

the new object. Is always the mutable version of the specified type.

Can be used in: Script tasks, Table triggers, Function fields

## parsePrimaryKey

parsePrimaryKey<primaryKeyType>(value: string): primaryKeyType

Parses a string to a primary key.

Example:

    uses core.complex as complex;

    export function getValue(): typeof _ebx.record.Supervisor
    begin
      var foreignKey := complex.parsePrimaryKey<typeof _ebx.record.Supervisor>('567');
      return foreignKey;
    end

Function Types :

primaryKeyType: the primary key type. Can be the type of a foreign key or an expression primaryKeyOf. Is mandatory.

Parameters :

value: a Stringcontaining the primary key internal representation to be parsed

Return :

the new mutable primary key object if the string is parsable, otherwise null.

Can be used in: Script tasks, Table triggers, Function fields

## primaryKeyOf

primaryKeyOf<primaryKeyType>(): primaryKeyType

Create an instance of a primary key type.

Note: A foreign key field contains a primary key on the referenced table.

Example:

    uses core.complex as complex;

    export function getValue(): typeof _ebx.record.Supervisor
    begin
      var foreignKey := complex.primaryKeyOf<typeof _ebx.record.Supervisor>();
      foreignKey.Id := 435;
      return foreignKey;
    end

Function Types :

primaryKeyType: the primary key type. Can be the type of a foreign key or an expression primaryKeyOf. Is mandatory.

Return :

the new primary key object. Is always mutable.

Can be used in: Script tasks, Table triggers, Function fields

Documentation > Developer Guide > EBX® Script > API