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. |
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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: