Events are well known in the NAV world today. Everybody is using this very nice feature. Not!?
No more table modifications for validations or extra features when inserting records. Only but advantages from my opinion. But recently I ran into an issue.
I have created a new table with some fields.
Then I created a hook codeunit with 2 functions based on the “OnAfterValidateEvent” trigger.
After everything was tested, the consultant or customer asked me to change the name of some fields. Not just the captions but also the name.
So as ask, I did the changes and compiled everything without an error. Where the fields were used on pages or in CAL everything was updated with the new field name. And it seems that it would work.
But after testing the solution again we ran into some issues. The validations of the fields were gone and no triggers were fired.
And after some investigation I found the problem in the “Event Subscription” page.
As you can see my subscription is broken because it couldn’t find the “Field”.
So let’s take a closer look to the problem.
Here is the list of the current fields in my table.
Now let’s take a closer look to my previous created subscriptions. And as you can see the “EventPublisherElement” isn’t updated.
And that was the reason why my “OnAfterValidateEvent” wasn’t raised.
The biggest issue here that you can’t find this problem with debugging, you only can find it if you look at the “Event Subscription”. But thanks to our “Event Helper” that waldo has already mentioned in this blog, the system warned me that there was a problem with my subscription.
My advice to you is: create your own “Event Helper” or maybe Microsoft can implement this by default.
Because otherwise you can ran into problems without knowing it.