uniface.SyntaxError

The uniface.SyntaxError object provides access to the error number and message of a field syntax error, and to the incorrect field value that caused the error. It is returned by the Field.getError function when used in the OnSyntaxError and OnSyntaxErrorResolved web triggers.

Syntax Error Properties

Property Name Description
exceptionCode Syntax error code.
message Syntax error message.
valueInError Field value that caused the syntax error.

Description

A uniface.SyntaxError object is generated when:

  • The user makes a syntax error in a field, which causes the OnSyntaxError web trigger to be fired.
  • The user corrects an error, which causes the OnSyntaxErrorResolved web trigger to be fired.

In these triggers, you can access the properties of the uniface.SyntaxError error object using the getError function of the field. For more information, see getError().

Using uniface.SyntaxError

For example, in the following code, the OnSyntaxError web trigger is used to display an alert box with the information about the error and the field it applies to. This trigger is activated when the browser detects a syntax error.

webtrigger OnSyntaxError
scope
   input
endscope

javascript
  //; this = the current field
  var vError = 'Error: ' +  this.getError().exceptionCode + this.getError().message + '\n'; Callout 1
  vError += 'in field ' + this.getLabel().getValue()  + '.\n'
  vError += 'The incorrect value is: ' this.getError().valueInError;

  alert(vError); Callout 2
  return true    Callout 3
endjavascript
  1.  Declare a variable called vError and assign a value that contains the error information, assembled using the functions of the uniface.Field object.
  2.  Display an alert with contents of the vError variable.
  3.  Return true to enable the default Uniface error handling, which puts a red border around the field.

Related Topics