How to Show Notifications to Users

You can show notifications on the form or field specific notifications. Use notifications to show help or error messages to the user.

Form Notification

Use form notifications to show general messages related to the form. Form notifications do not stop the saving of the form.

To show a form notification use the Client API functions setFormNotification and to clear a form notification use ui.clearFormNotification.

Definition

formContext.ui.setFormNotification(message, level, uniqueid)

setFormNotification (Client API reference)
ui.clearFormNotification (Client API reference)

Example

this.EmailAddressOnChange = function(executionContext) {
    var formContext = executionContext.getFormContext();
    var emailAddress = formContext.getAttribute("emailaddress1").getValue();

    var emailValidExpression = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
    var messageId = "emailValidationMessage";
    if(!emailValidExpression.test(emailAddress)) {
        formContext.ui.setFormNotification("Validation errors detected.", "ERROR", messageId);
    } else {
        formContext.ui.clearFormNotification(messageId);
    }
}

Field Notification

Use field notifications to show validation errors related to a field. Field notifications prevent the user from saving the form.

To show a field notification use the Client API function setNotification and to clear a field notification use control.clearNotification.

Definition

formContext.getControl(arg).setNotification(message,uniqueId);

setNotification (Client API reference)
control.clearNotification (Client API reference)

Example

this.EmailAddressOnChange = function(executionContext) {
    var formContext = executionContext.getFormContext();
    var emailAddress = formContext.getAttribute("emailaddress1").getValue();

    var emailValidExpression = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
    var messageId = "emailValidationMessage";
    if(!emailValidExpression.test(emailAddress)) {
        formContext.getControl("emailaddress1").setNotification("E-Mail address not valid.", messageId);
    } else {
        formContext.getControl("emailaddress1").clearNotification(messageId);
    }
}