๐ 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