Notifications in Business Central AL
How to create notifications safely on the active page in Business Central using AL?
var
MyNotification: Notification;
local procedure ShowNotification()
var
NotificationMessage: Label 'Your Notification Message.';
begin
MyNotification.Scope := NotificationScope::LocalScope;
MyNotification.Message := NotificationMessage;
if ShouldNotify then
MyNotification.Send()
else
if not (IsNullGuid(MyNotification.Id)) then
MyNotification.Recall();
end;
What is important to note is that you must do a IsNullGuid check before you attempt to recall your notification. If there is no active notification, it will shoot an error message.
Reference -