Display field messages

Rather than use JavaScript alert(), for a cleaner look, you can display an error on the form itself. The methods showFieldMsg() and hideFieldMsg() can be used to display a message just below the field itself.

showFieldMsg and hideFieldMsg are methods that can be used with the g_form object.

These methods are used to make changes to the form view of records (Incident, Problem, and Change forms). These methods may also be available in other client scripts, but must be tested to determine whether they will work as expected.

When a field message is displayed on a form on load, the form will scroll to ensure that the field message is visible, ensuring that users will not miss a field message because it was off the screen.

A global property (glide.ui.scroll_to_message_field) is now available that controls automatic message scrolling when the form field is offscreen (scrolls the form to the control or field).

Table 1. Method Detail
Method Detail Parameters Example
showFieldMsg(input, message, type, [scrollform])
  • input - name of the field or control
  • message - message you would like to display
  • type - either 'info' or 'error', defaults to info if not supplied
  • scroll form - (optional) Set scrollForm to false to prevent scrolling to the field message offscreen.

Error Message

g_form.showFieldMsg('impact','Low impact not allowed with High priority','error');

Informational Message

g_form.showFieldMsg('impact','Low impact response time can be one week','info');
//or this defaults to info type
//g_form.showFieldMsg('impact','Low impact response time can be one week');

  • input - name of the field or control
  • clearAll - (optional) boolean parameter indicating whether to clear all messages. If true, all messages for the field will be cleared; if false or empty, only the last message will be removed

Removing a Message

//this will clear the last message printed to the field

Legacy support

The showErrorBox() and hideErrorBox() are still available but simply call the new methods with type of error. It is recommended that you use the new methods.