Step 2 – Notifications | ForNAV App Building

I’m building an App to work with ForNAV. If you haven’t you should read earlier posts first or watch the YouTube channel.

New Blog Series | Building the ForNAV App

Step 1 – Renumbering | ForNAV App Building

Notifications

The next step I will blog about is how to make notifications work for you.

Why Notifications?

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:

Notification1

To show this notification I have created 4 codeunits:

  • ForNAV Notifications
  • ForNAV Notification Actions
  • ForNAV Initialize Notification
  • ForNAV Notification IDs

ForNAV Notifications

Let’s start with the first and look at the code:

Notification2.png

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

Notification3

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

Notification4

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.

Notification5

ForNAV Notification IDs

Notification6

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.

That’s it

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.

Wizard1

 

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.