Dynamics 365 – Form Notifications Using Javascript

Notifications are useful when you want to show field specific notifications or form level notifications when some fields change. They can be triggered on change of a field, Onload or Onsave events of the form. You write them in Javascript and register to the form events by Form editor.

Form Level Notifications

  • Form Level Notifications – Set Notification
    formContext.ui.setFormNotification(message, messageType, uniqueId);
  • Form Level Notifications – Clear Notification
    formContext.ui.clearFormNotification(uniqueId);
function FormLevelNotifications(executionContext) {
    var formContext = executionContext.getFormContext();
    formContext.ui.setFormNotification("Simple ERROR notification. ", "ERROR");
    formContext.ui.setFormNotification("Simple WARNING notification. ", "WARNING");
    formContext.ui.setFormNotification("Simple INFORMATION notification.", "INFO");

    formContext.ui.clearFormNotification(errorId);
    formContext.ui.clearFormNotification(warningId);
    formContext.ui.clearFormNotification(infoId);
}

Field Specific Notifications

  • Field Specific Notifications – Set Notification
    formContext.getControl(fieldLogicalName).setNotification(message, uniqueId);
  • Field Specific Notifications – Clear Notification
    formContext.getControl(fieldLogicalName).clearNotification(uniqueId);
function FieldSpecificNotifications(executionContext) {
    var formContext = executionContext.getFormContext();
    // if email address does not have '@' character
    formContext.getControl("emailaddress1").setNotification("Email Address must have contain '@' character", emailError");
    //else
    formContext.getControl(emailaddress1).clearNotification("emailError");
}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s