Subscribing to global events
Global events are raised by codeunit 1 ApplicationManagement
in response to certain application-wide actions, such as opening and closing the company or opening the user's default role center.
How to do it...
The following recipe will show how to subscribe to the global events OnCompanyOpen
and OnCompanyClose
to log user activities in each company. Event information will be stored in a separate table.
- Create a table in NAV table designer. Open the table properties window, from the View menu, select the Properties option, or press
Shift
+
F4
. Update the value of the property
DataPerCompany
from the default valueYes
toNo
. - Create four fields, as shown in the following table:
Field No.
Field Name
Data Type
Length
1
Event ID
Integer
2
Event Type
Option
3
User ID
Code
50
4
Company Name
Text
50
5
Event Date
Date
6
Event Time
Time
- Select the field 1
Event ID
and open its properties. In the propertyAutoIncrement
, change the...