Adding Notifications in Microsoft Dynamics 365 Business Central
Introduction:
Notifications provide a programmatic way to send non-intrusive information to the user interface (UI) in the Microsoft Dynamics 365 Business Central. Their purpose is to provide users with some information about a current situation without any necessity to perform or block an action.
Pre-requisites:
1. Microsoft Dynamics 365 Business Central
Steps:
1. Create a global variable of the type notification:
LoadsNotification: Notification;
2. The different functions used in notification are as follows:
Message: It includes the message to be shown in the notification
Scope: Specifies the scope where the notification appears.
AddAction: To add an action to notification
SetData: To set the data property value in a notification
GetData: To get the data property value in a notification
Recall: To recall a sent notification
Send: To send the notification to the user.
3. In this case I have used the notification function to be displayed if the ColorVar is unfavorable i.e. red and the day is Thursday, Friday, Saturday or Sunday. If the above condition is satisfied then the notification is displayed with an action to schedule Loads otherwise no notification is displayed. The code is as follows:
if ((ColorVar = 'Unfavorable') and (UnscheduledLoadsCount > 0)) then begin LoadsNotification.Message('There are ' + Format(UnscheduledLoadsCount) + ' loads yet to be scheduled.'); LoadsNotification.Scope(NotificationScope::LocalScope); LoadsNotification.AddAction('Schedule Loads', Codeunit::EventHandlingCU, 'OpenUnscheduledLoadsByVendor'); LoadsNotification.send; end;
The Procedure OpenUnscheduledLoadsByVendor is created in the codeunit EventHandlingCU to open the page when action is triggered.
procedure OpenUnscheduledLoadsByVendor(LoadsNotification: Notification): Text begin Page.Run(50139); end;
Conclusion:
Thus, this way notifications can be created in Business Central to notify the users some important information without blocking actions of the users.