So today a colleague referred me to this page on MSDN where it states the following about the ID:
If left unassigned the notification will be assigned an ID when the SEND method is called. For more information, see SEND Function (Notification).
So this sounds like giving your own unique ID to the notification is not that necessary at all, right?
After some testing it appears not to be that easy..
As I mentioned in my first blog post about notifications a notification without a unique ID can cause a huge stack of duplicate notifications on your screen and we DO NOT want that at all.
If you leave the ID empty and you let the SEND function generate an ID for you, the ID will be kept in memory BUT only if the notification variable is kept somewhere global (I hope you won’t even consider doing this)
You can think of all kind of fancy functions that will return the ID that the SEND function has generated for you, but in my perception the way to go is to create a function per notification to retrieve the hard coded guid.
P.S. this is also the way Microsoft is doing it.
A colleague of mine came across this issue which looked like a bug at first.
When I for example have two posted credit memos within a different resposibility center than I’ve set up in for myself or in the company information, this will happen…
This is probably in the application for ages but shouldn’t NAV be intuitive? Since we’ve got notifications now, I would at least expect a notification why some documents are not shown when for example navigating to the Posted Sales Credit Memos list OR completely integrate responsibility centers and let the factbox take the responsibility centers into account (which is a lot of work since this cannot be done with the current FlowFields)
Now we have to decide wheter or not we want add our new notification to table 1518, adding it means we give the user the possibility to disable and add extra conditions (depending on the function we use to add it) to the notification.
In order to add our new notification in table 1518 we have to create a new subscriber function which subscribes to the event called OnInitializingNotificationWithDefaultState in page 1518.
Now we’ve got two functions in table 1518 to choose from:
– InsertDefault (basic notification)
– InsertDefaultWithTableNum (conditional notification)
If we decide to give the user the possibility to disable the notification we should also check if the notification is enabled before sending it.
We can do that by one of the following functions in table 1518:
– IsEnabled (checks if present/enabled)
– IsEnabledForRecord (checks if present/enabled and if conditions were met)
Note: if the notification is not present in table 1518 the functions will return TRUE.
After implementing all of the logic above our codeunit will now look like this:
With NAV 2017 we got the all new notification data type, let’s see how we can create a very simple notification and send it to the user.
So let’s say we want to send a notification to the user when he leaves the item description empty or when he empties the item description, sounds easy right?
In this case I’ve created one function which is called from the two EventSubscribers called SendOrRecallDescriptionNotification.
This function will either send the notification to the user or recall it if the Description is filled in, in the meantime.
Notifications always need a unique Id, in this case a Guid, we obviously create this Guid with the PowerShell New-Guid Cmdlet!
If you don’t provide the Notification with an ID you will en up with something like this 🙂
In part 2 I’ll explain how to register our new notification in table 1518 and if we want to give the user the ability to apply extra conditions on the visibility of the notification.
So a few weeks ago I came across this problem and thought I might as well share it with you guys.
Somewhere in the system we had a GET on the purchase document based on the approval entry.
The GET failed so the document was gone, I started looking for a DELETE(FALSE) on the purchase header and came across report 499 – Delete Invoiced Purch. Orders, which did not delete the related approval entries.
Above applies to the following sales and purchase reports:
– 291 Delete Invd Blnkt Sales Orders
– 299 Delete Invoiced Sales Orders
– 491 Delete Invd Blnkt Purch Orders
– 499 Delete Invoiced Purch. Orders
– 5914 Delete Invoiced Service Orders
– 6651 Delete Invd Sales Ret. Orders
– 6661 Delete Invd Purch. Ret. Orders
The reports were fixed in cumulative update 5 for NAV2015, but the records are still out there waiting for a clean up!