GlideElement - setError(String message)

Adds an error message.

Can be retrieved using getError().

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
void

Scoped equivalent

To use the setError() method in a scoped application, use the corresponding scoped method: Scoped GlideElement - setError(String errorMessage).

if ((!current.u_date1.nil()) && (!current.u_date2.nil())) {
  var start = current.u_date1.getGlideObject().getNumericValue();
  var end = current.u_date2.getGlideObject().getNumericValue();
  if (start > end) {
    gs.addInfoMessage('start must be before end');
    current.u_date1.setError('start must be before end');
    current.setAbortAction(true);
  }
}