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

Unit core.message

Script unit that provides methods to create and manage user messages

Methods

procedure addError(message: string)

Adds the specified error message to the current validation context.

procedure addInfo(message: string)

Adds the specified info message to the current validation context.

function addLocale(userMessage: user_message, message: string, locale: locale): user_message

Adds a locale to a user message.

procedure addMessage(message: user_message)

Adds the specified user message to the current validation context.

procedure addRecordMessage(record: record, message: user_message)

Adds the info message to the current validation context for the specified record.

procedure addWarning(message: string)

Adds the specified warning message to the current validation context.

procedure addXPathMessage(xPath: string, message: user_message)

Adds the user message to the current validation context for the records that match the specified XPath predicate.

function of(message: string, locale: locale): user_message

Creates an instance of a user message for a single locale.

function ofBundleError(path: string, key: string, parameters: list<object>): user_message

Creates an instance of an error user message from messages bundle.

function ofBundleInfo(path: string, key: string, parameters: list<object>): user_message

Creates an instance of an info user message from messages bundle.

function ofBundleWarning(path: string, key: string, parameters: list<object>): user_message

Creates an instance of a warning user message from messages bundle.

function toString(userMessage: user_message, locale: locale): string

Formats the message with the specified locale.

addError

procedure addError(message: string)

Adds the specified error message to the current validation context.

Example:

uses core.message as msg;
...
export procedure checkRecord(record : .Project)
begin
  msg.addError('This is an error message');
end
...

Parameters:

message: the string message.

Can be used in:

addInfo

procedure addInfo(message: string)

Adds the specified info message to the current validation context.

Example:

uses core.message as msg;
...
export procedure checkRecord(record : .Project)
begin
  msg.addInfo('This is an info message');
end
...

Parameters:

message: the string message.

Can be used in:

addLocale

function addLocale(userMessage: user_message, message: string, locale: locale): user_message

Adds a locale to a user message.

Example:

uses core.message as msg;
export procedure executeScriptTask()
begin
  var fr:=locale.of('fr','FR');
  var en:=locale.of('en','EN');
  var messageEn:=msg.of('A new message',en);
  var message:=msg.addLocale(messageEn,'Un nouveau message',fr);
end

Parameters:

userMessage: the user message.

message: the string message in the locale"s language. If null, the empty string is used.

locale: the locale. if null, the default locale is used.

Return:

a new message with the added locale. If the input userMessage is null, creates a new user message with only the specified locale.

Can be used in:

addMessage

procedure addMessage(message: user_message)

Adds the specified user message to the current validation context.

Example:

uses core.message as msg;
...
export procedure checkRecord(record : .Project)
begin
  var userMessage:=msg.ofBundleError('Key.invalid.value', 'Bundle/path');
  msg.addMessage(userMessage);
end
...

Parameters:

message: the user message.

Can be used in:

addRecordMessage

procedure addRecordMessage(record: record, message: user_message)

Adds the info message to the current validation context for the specified record.

Example:

uses core.message as msg;
...
export procedure checkTable()
begin
  var xpath :='/root/table[./id=15]';
  var record := d.lookupRecordByFullXPath(table, xpath);
  var userMessage:=msg.ofBundleInfo('Key.key2', 'Bundle/path');
  msg.addRecordMessage(record,userMessage);
end
...

Parameters:

record: the record.

message: the user message.

Can be used in:

addWarning

procedure addWarning(message: string)

Adds the specified warning message to the current validation context.

Example:

uses core.message as msg;
...
export procedure checkRecord(record : .Project)
begin
  msg.addWarning('This is a warning message');
end
...

Parameters:

message: the string message.

Can be used in:

addXPathMessage

procedure addXPathMessage(xPath: string, message: user_message)

Adds the user message to the current validation context for the records that match the specified XPath predicate.

Example:

uses core.message as msg;
...
export procedure checkTable()
begin
  var userMessage:=msg.ofBundleError('key.key1', 'Bundle/path');
  msg.addXPathMessage('./number<100',userMessage);
end
...

Parameters:

xPath: the XPath predicate of the records to which the message applies.

message: the user message.

Can be used in:

of

function of(message: string, locale: locale): user_message

Creates an instance of a user message for a single locale.

Example:

uses core.message as msg;
export procedure executeScriptTask()
begin
  var en:=locale.of('en','EN');
  var message:=msg.of('A new message',en);
end

Parameters:

message: the string message in the locale"s language. If null, the empty string is used.

locale: the locale. if null, the default locale is used.

Return:

the new user message.

Can be used in:

ofBundleError

function ofBundleError(path: string, key: string, parameters: list<object>): user_message

Creates an instance of an error user message from messages bundle.

The user message from the bundle can be created by specifying a path and a key in the EBX IDE.

Example:

uses core.message as msg;
...
export procedure check()
begin
  // the error message from the bundle: 'The reference {0} must start with "TIBCO"'
  // the reference id is passed as parameter to the message
  var message:= message.ofBundleError('bundle/path','reference.starts.tibco',_ebx.root.reference_id);
end
...

Parameters:

key: the key of the message in the bundle.

parameters: the parameters of the message.

Return:

the new user message.

Can be used in:

ofBundleInfo

function ofBundleInfo(path: string, key: string, parameters: list<object>): user_message

Creates an instance of an info user message from messages bundle.

The user message from the bundle can be created by specifying a path and a key in the EBX IDE.

Example:

uses core.message as msg;
export procedure executeScriptTask()
begin
  // the info message from the bundle: 'The script task {0} has been executed successfully'
  // the workflow id is passed as parameter to the message
  var message:= message.ofBundleInfo('bundle/path','script.task.info',_ebx.workflow.id);
end

Parameters:

key: the key of the message in the bundle.

path: the path of the bundle.

parameters: the parameters of the message.

Return:

the new user message.

Can be used in:

ofBundleWarning

function ofBundleWarning(path: string, key: string, parameters: list<object>): user_message

Creates an instance of a warning user message from messages bundle.

The user message from the bundle can be created by specifying a path and a key in the EBX IDE.

Example:

uses core.message as msg;
...
export procedure checkRecord(record : .Department)
begin
  // the warning message from the bundle: 'The location of the department {0} is mandatory'
  // the department is passed as parameters to the message
  var message:= message.ofBundleWarning('bundle/path','location.mandatory',record.department_id);
end
....

Parameters:

key: the key of the message in the bundle.

path: the path of the bundle.

parameters: the parameters of the message.

Return:

the new user message.

Can be used in:

toString

function toString(userMessage: user_message, locale: locale): string

Formats the message with the specified locale.

Example:

uses core.message as msg;
export procedure executeScriptTask()
begin
  var label:=_ebx.workflow.label;
  var englishLabel:=msg.toString(label,locale.of('en','EN'));
  var frenchLabel:=msg.toString(label,locale.of('fr','FR'));
end

Parameters:

userMessage: the user message.

locale: the locale. If null, the default locale is used.

Return:

the string message formatted with the specified locale or null if the input userMessage is null.

Can be used in:

Documentation > Developer Guide > EBX® Script > API