How to do it...

To create a data-event handler, follow these steps:

  1. Create a new SalesConfirmHeaderTmp_ConVMSSalesReports_DataHandler class.
  2. Open the table design for the table in question; in our case, double-click on the SalesConfirmHeaderTmp.ConVMSSalesReports table extension.
  3. Expand Events and locate onInserting.
The onInserted event is too late as we want to fill in a field before the record is written; if we subscribe to onInserted, the data will not be saved.
  1. Right-click on the Event and choose the Copy event handler method. This will create a code snippet, and place it in the paste buffer.
  1. Open the SalesConfirmHeaderTmp_ConVMSSalesReports_DataHandler class, and paste in the code snippet generated in step 4 into the class body, ...

Get Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.