Cloud Software Group, Inc. EBX®
Documentation > Developer Guide > EBX® Script > Usage
Navigation modeDocumentation > Developer Guide > EBX® Script > Usage

Function field

Introduction

The DSL (Domain Specific Language) is used to define a function field. For more information on DSL, see Reference

To create and modify a function field, use the Data Model Assistant (DMA) .

The Data Model Assistant (DMA) includes a script editor that provides contextual code completion.

Initial script

Introduction

When a function field is first edited using use the Data Model Assistant (DMA) , EBX® provides an initial script with the correct definition of the exported function.

The following example is a script created for a function field of type string:

// Returns the full name.
export function getValue(): string
begin
  if isNull(record.FirstName) then
    return _ebx.record.LastName;

	return _ebx.record.FirstName | ' ' | _ebx.record.LastName;
end

Exported function

An exported function can be called directly by EBX®. Only one exported function is allowed per script. Its signature (name, and return type) depends on the type of the function field and should not be changed..

For the field of a record, definition must be similar to:

export function getValue(): typeof _ebx.record.<path>
begin
	...
end

For the field of a dataset, definition must be similar to:

export function getValue(): typeof _ebx.root.<path>
begin
	...
end

Predefined variable

Introduction

Predefined variables allow access to the context of the function field. The following contextual variable is specific to function fields. It is constant and of an immutable complex type. For more details on common predefined variables, see the Reference .

Record

The predefined variable _ebx.record is available only if the current script is for a function field of a table. It allows read-only access to the current record.

Its fields are defined by the current EBX® schema.

Example:

// Returns the full name.
export function getValue(): string
begin
	return _ebx.record.FirstName | ' ' | _ebx.record.LastName;
end
Documentation > Developer Guide > EBX® Script > Usage