Introduction:Today, as I was playing around in Business Central with some of my customization for General Journals where I wanted to flow a field from General Journal to G/L Entries using Event Subscriber, I noticed something weird.
Microsoft Dynamics Business Central
- As I was looking for an Event which will trigger when General Journal Entries are posted, I found these entries by browsing through Codeunit 12 Gen-Jnl Post.
- I found that 'OnAfterRunWithoutCheck' event works. So I proceeded to confirm by adding a Simple Hello World Message in the Event Subscriber and the message didn't pop. Thus, I wasn't sure if that was the specific event to subscribe to.
|Message Added to Event Subscriber|
|No Message appeared after Posting|
- I tried with a list of Event Subscribers and also, Table Triggers(OnBeforeDelete, OnAfterInsert) do not work during posting
- Frustrated unable to find the issue, I realised I missed using Event Recorder. Trying Event Recorder again popped up the same event () I was working on earlier
- I added Error this time and it popped up. I was surprised to see this concluding this is something new.
|Error added to Event Subscriber|
|Error message pop-up|
To sum up, this weird behaviour is present in Business Central Version (Version: Platform 14.0.32600.35035 + Application 34422 (US Dynamics NAV 14.1))
Also, I noticed that the Global Variables in the Codeunit you create for a specific Event Subscriber is cleared out when you use them in other Event Subscriber of the same Codeunit.
Hope this helps :)