Creating custom events
The capabilities of custom application code are not limited by event subscription. Customized objects can raise predefined business or integration events, and publish new custom events.
How to do it...
The following recipe explains how to create a new event in codeunit 21 Item Jnl.-Check Line
. that will fire on journal line verification, before any other line validation code.
- In the NAV development environment, select the codeunit 21
Item Jnl.-Check Line
and click the Design button to access its C/AL code. - Open the C/AL Globals window, tab to Functions and insert a new function in the list -
OnBeforeCheckItemJnlLine
. - Click the Locals button located in the right panel. This will open the list of function parameters. Add one parameter:
Var
Name
DataType
Subtype
True
ItemJnlLine
Record
Item Journal Line
- Close the C/AL Locals to return to the list of functions, then open the properties of the function
OnBeforeCheckItemJnlLine.
- In the field
Event
, choose the option...