๐Ÿ”” Notifier Helper

Utility functies voor het tonen en beheren van meldingen binnen Dataverse forms (alerts, field notifications en form notifications).

โ† Terug naar Core Library

๐Ÿ“– Introductie

De Notifier Helper biedt een gestandaardiseerde manier om meldingen te tonen binnen model-driven apps. Hiermee kunnen foutmeldingen en waarschuwingen consistent worden weergegeven op veld-, formulier- of popup-niveau.

๐Ÿ‘‰ Zorgt voor consistente validatie feedback en voorkomt ongecontroleerde save acties.

๐Ÿ“ฆ Functionaliteit

๐Ÿ“ข Meldingen tonen

  • showAlert(message, fieldName, executionContext, title, width, height) โ†’ Toont alert dialog + optioneel field notification + blokkeert save
  • showFormNotification(message, uniqueId, executionContext) โ†’ Toont melding bovenaan formulier
  • showFieldNotification(message, fieldName, executionContext) โ†’ Toont melding op veld

๐Ÿงน Meldingen verwijderen

  • clearField(formContext, fieldName) โ†’ Verwijdert field notification
  • clearForm(formContext, uniqueId) โ†’ Verwijdert form notification
  • clearAlerts(formContext, fieldName, uniqueId) โ†’ Verwijdert beide

โš™๏ธ Werking

De helper biedt een abstractielaag voor het tonen en beheren van notificaties binnen de Dataverse form lifecycle.

๐Ÿ‘‰ De helper gebruikt:
  • Popup alerts via Xrm.Navigation
  • Form notificaties via UI API
  • Field notificaties via controls

1. Opslaan blokkeren

  • executionContext.getEventArgs().preventDefault()

2. FormContext ophalen

  • executionContext.getFormContext()
  • Fallback: Xrm.Page (legacy)

3. Notificaties tonen

  • Xrm.Navigation.openAlertDialog()
  • formContext.ui.setFormNotification()
  • control.setNotification()

4. Identificatie via IDs

  • Unieke ID's voor form notificaties
  • Vaste prefix voor field notificaties

โš ๏ธ Belangrijke aandachtspunten

  • preventDefault()
    Wordt automatisch uitgevoerd bij validatiefouten
  • Field notifications
    Gebruiken ID: FIELD_ERR_<fieldName>
  • Form notifications
    Vereisen unieke uniqueId
  • ExecutionContext
    Nodig bij events zoals OnSave en OnChange
  • Fallback naar Xrm.Page
    Voor legacy ondersteuning
โš ๏ธ Gebruik consistente uniqueId's om notificaties later correct te kunnen verwijderen.

๐Ÿ’ก Voorbeelden

Alert tonen + save blokkeren

onited.core.Notifier.showAlert(
  "Email is verplicht",
  "emailaddress1",
  executionContext
);

๐Ÿ“Š Samenvatting

โœ… Centrale notificatie logica
โœ… Ondersteunt alert, form en field meldingen
โœ… Blokkeert save bij validatiefouten
โœ… Consistente afhandeling met unieke IDs