I’m building an App to work with ForNAV. If you haven’t you should read earlier posts first or watch the YouTube channel.
The next step I will blog about is how to make notifications work for you.
Notifications are very useful when you want to ask something from the user without sitting on their face and be rude.
I am going to use a notification to indicate that ForNAV is installed but not yet setup. This can happen if people install the fob or if they activated the extension.
This will be the notification users will see:
To show this notification I have created 4 codeunits:
- ForNAV Notifications
- ForNAV Notification Actions
- ForNAV Initialize Notification
- ForNAV Notification IDs
Let’s start with the first and look at the code:
You can see I have an EventSubscriber that subscribes in my case to OnFindPrinter in Codeunit 1. Some people like to subscribe to Activity Pages of Role Centers but what if someone uses my App in a database with new rolecenters.
ForNAV is a report tool so why not remind them to setup when they do printing.
In fact, Microsoft should provide a generic handle for notifications like this.
Anyway, I throw a notification, but I don’t want to show the notification when the setup if already done, or if the user does not want to setup ForNAV and disables the notification.
The notification has an ID and two actions. “Yes” would be the prefered one or “No” if for whatever reason they don’t want to do the setup.
ForNAV Notification Actions
The Actions are handled in a seperate codeunit. The first action starts the setup process which uses a wizard. More about that in the next blog.
The second action checks if the notification exists in the MyNotifications table and disables.
ForNAV Initialize Notification
NAV 2017 has a table that stores notification preferences. This is table 1518 My Notifications and the Page that belongs to this table supports the “Discovery Event” pattern. This means I can hook into this page and “insert” myself the first time this is possible.
I can do this using the “InsertDefaultWithTableNum” function.
ForNAV Notification IDs
The last codeunit is a silly one, it returns the GUID as a string. This GUID is used in three different places in my code and I don’t want to change it in three places when I have to.
Let me end with a teaser for the next blog, a Setup Wizard. This is what you get when you hit “Yes” on the notification.