How to test your event subscriptions
Many developers have started using the events that are raised in Dynamics NAV, and some have even started adding events to their solutions. There is some concern that a subscription will break if the interface of an event is changed. As a developer, you can verify that the subscription is active by running page 9510, Event Subscriptions.
When I work with a subscription, I often apply the following code to extend the Event Subscriptions page.
I start by adding the table.
Then, on the Event Subscriptions page, I add the following action.
Lastly, I add three lines at the end of the OnAfterGetRecord function:
Now, I can toggle a Gate Me flag on the page.
Normally, I would like a wake-up call when I start the client in case I introduced a breaking change. I do this by creating a subscriber to the OnAfterCompanyOpen event.
And yes, I do get this error from time to time.
How to write tests for event subscriptions
It is very simple to write a unit test for a subscription that has been added.
And by running the test tools, the test can be run like any other test.
Best regards,
Anders Larsen
Senior Engineering Lead, Dynamics NAV Application Team