Previously I wrote about new feature Notifications in following blog Notifications.Today will explain how to write/develop notifications.
Notifications provide a programmatic way to send non-intrusive information to the user interface (UI) in the Dynamics NAV Web client. Notifications differ from messages initiated by the MESSAGE function. Messages are modal, which means users are typically required to address the message and take some corrective action before they continue working. On the other hand, notifications are non-modal. Their purpose is to notify users about a current situation, but do not require any immediate action or block users from continuing with their current task. For example, you could have a notification that a inventory balance is low or customer have overdue balance etc.
Notifications are not stopping the users from going ahead as it will display the notifications in notification bar i.e on top of the page (just like validation errors).User can dismiss the notification and continue working.
- Multiple notification will appear chronological order from top to bottom
- Notification remain available until page instance or until user dismiss it.
- Sub page notification will also display on top of page.
- Validation will be shown before notification
By using the Notification and NotificationScope data types and functions in C/AL, you can add code to send notifications to users. The following table provides an overview of the available functions. The sections that follow provide additional information about how to create notifications.
|MESSAGE||Specifies the content of the notification that appears in the UI.|
|SCOPE||Specifies the scope in which the notification appears.|
|SEND||Sends the notification to be displayed by the client.|
|ADDACTION||Adds an action on the notification.|
|SETDATA||Sets a data property value for the notification|
|GETDATA||Gets a data property value from the notification.|
How to develop Notification
1) Create and send notification
2) Defining notification scope
There are two different scopes: LocalScope and GlobalScope.
- A LocalScope notification appears in context of the user’s current task, that is, on the page the user is currently working on. LocalScope is the default.
- A GlobalScope notification is not directly related to the current task. Note: Global Scope is currently not supported, so do not use it. This will be implemented in a future release.
3) Adding action to notification
4) Sending data with a notification
Suppose user want to get notification for Inventory zero then one can write
Define ItemInventoryNotification as Notification Datatype
If Item.Inventory<=0 THEN BEGIN
ItemInventoryNotification.MESSAGE(‘Inventory zero for this item’);
Stay Tuned for more updates and keep testing….