-
Handling D365 form notifications
JavaScript
Handling D365 form notifications : Displays notifications based on thresholds.
This snippet checks a value attribute in Dynamics 365 and displays
error,
warning, or
info notifications based on thresholds.
//Displays notifications based on thresholds.
function DisplayNotification(executionContext) {
const formContext = executionContext.getFormContext();
const score = formContext.getAttribute("pps_score")?.getValue();
if (score < 10) {
formContext.ui.setFormNotification("The score is too low!", "ERROR", "scoreNotification");
} else if (score >= 10 && score < 50) {
formContext.ui.setFormNotification("The score is average!", "WARNING", "scoreNotification");
} else if (score >= 50) {
formContext.ui.setFormNotification("Good! The score is okay!", "INFO", "scoreNotification");
}
}