Manual event subscription

In all event subscribers we created in this chapter, subscription was activated as soon as the Subscriber function was saved and compiled. But this is not necessary; subscription can be started manually by C/AL code. Now, we will see how to activate subscription on demand.

This example will subscribe to a custom event raised on the creation of a general journal line from a customer payment record. We will use it to show a progress bar window with the number of processed lines. Event subscription will help separate the user interface (progress window) from the line-processing code, and enable the window when needed simply by activating the subscription.

Journal lines are created in codeunit 50504 Customer Payments ...

Get Microsoft Dynamics NAV Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.