Stop Using Native alert() and confirm()
APEX’s apex.message API provides themed, accessible, non-blocking notifications that match your application’s visual style.
Success Messages
apex.message.showPageSuccess("Order #1234 approved successfully.");
Error Messages
apex.message.showErrors([{
type: "error", location: ["page","inline"],
pageItem: "P10_EMAIL", message: "Invalid email format"
}, {
type: "error", location: ["page","inline"],
pageItem: "P10_PHONE", message: "Phone number is required"
}]);
apex.message.clearErrors();
Confirmation Dialogs
apex.message.confirm("Delete this order?", function(okPressed) {
if (okPressed) {
apex.server.process("DELETE_ORDER", {x01: orderId}, {
success: function() {
apex.message.showPageSuccess("Order deleted.");
apex.navigation.redirect("f?p=&APP_ID.:1:&SESSION.");
}
});
}
});
Alert Dialogs
apex.message.alert("Session expires in 5 minutes.", function() {
// runs after user clicks OK
});
Custom Toast Notifications
function showToast(msg, type) {
var $t = $('<div class="u-notification">').text(msg)
.css({position:'fixed',top:'60px',right:'20px',zIndex:9999,
padding:'12px 20px',borderRadius:'4px',opacity:0})
.appendTo('body').animate({opacity:1},200);
setTimeout(function(){$t.animate({opacity:0},400,function(){$t.remove()});},3000);
}
showToast("Auto-saved at " + new Date().toLocaleTimeString(), "success");