Publish, Raise and Subscribe
Something about NAV Events (Integration & Business Events)…. Some Definitions of: “Publishers & Subscribers”
“A publisher” exposes hook-points in code or processes that other partners or sub-systems can leverage. ISVs and Microsoft are the typical providers of published events, but not necessarily the only providers. Events are raisedthrough explicit function calls, or raised implicitly by the Microsoft Dynamics NAV Runtime.
“A subscriber” subscribes to and handles events. When an event is raised, the subscription code is automatically called by the runtime. This enables partners to hook into core Microsoft Dynamics NAV functionality without having to do ‘classic’ code modification. Any Microsoft Dynamics NAV solution provider, including Microsoft, can use event subscriptions.
Example new codeunit “80000 My Publisher”
“Publisher” Event
> Codeunit 80000 Function [Integration Event] OnItemCodeRenamed(parItem:Code20)
“Subscribe” Event
> Codeunit 80000 Functions ErrorItemRenaming(“No.”)
- EventPublishedObject “Codeunit My Publishers”
“Publisher & Subscriber”
- Void Containers only “to map Events” in events list
- Publisher Integration Event > ex. OnItemCodeRenamed(“No.”)
- Subscriber EventSubscriber > ex. ErrorItemRemaining(“No.”)
“Raise Event”
On Table 27 Item –> No. OnValidate()
- cdyMyPublisher.OnItemCodeRenamed(“No.”); // Raise Event > Call codeunit function on No. Onvalidate Trigger
MAPPING EVENTS
->“NEW EVENT IS NOW PUBLISHED AND AVAILABLE”; Now “new EVENT” is mapped and available to use on EVENT FUNCTIONS LIST
“Event Function”
- Example OnItemCodeRenamed(parItemNo:Code20) mapped on EventFunction
Publisher
- OnEvaluateField(“No.”)> raising EventFunction “OnBeforeValidateEvent(“No.”)
“EVENTS SUBSCRIPTIONS LIST”
- My Custom Codeunit (raiser) with exposed function is available on subscriptions event list
- In this case is: “Business Event” published from table 27 by OnBeforeValidateEvent Function
RUNNING (RAISING)
- Example of raising ERROR(“No.”) function when ErrorItemRemaing() function is running
… you can find a lot of information about NAV Events on NAV team blog and MSDN Online
-Integration Events in Microsoft Dynamics NAV 2016
https://blogs.msdn.microsoft.com/nav/2015/10/15/integration-events-in-microsoft-dynamics-nav-2016/
–Introducing Events -> https://msdn.microsoft.com/en-us/library/mt299398(v=nav.90).aspx
–Get Starting With Eventing -> https://msdn.microsoft.com/dynamics/nav/mt598589