- Open Business Central Web Client and search for Event Recorder
- Open Event Recorder in a new page
This step is essential, otherwise the Event Recorder will not record any event.
- Start recording the events
Press action Start, in the Record Events action group, and do not close the Event Recorder page.
- Post the Sales Invoice and stop the Event Recorder
After posting the Sales Invoice, go back to the Event Recorder page and press the Stop action in the Record Events action group. A message with the number of recorded events should be shown.
- View the recorded events
A list with the recorded events should be presented. Since that are a lot of events that happened in the posting but are not related to posting, we can filter the list so show us, for instance, just the events that occur in the posting Codeunit.
- Subscribe the event
Having found the event to subscribe, the next step is to subscribe the event in AL. In Event Recorder, next to the Calling Method column, there is a Get AL Snippet action that will return a message with the Event Subscriber definition. Just copy the message content and paste it in your AL project.
Another way to subscribe to the event is to use the command AL: Find Event (Alt+Shift+E) in VS Code. Just type the name of the event to subscribe the event is automatically brought to our Codeunit.