Using metadata for data access
All tables and fields within Dynamics 365 for Operations have an ID. The table ID can be used to generate an instance of the table, and we can work with that table as if we had declared it as a type in a method, making our code more generic and more easily extendable.
In this example, we will write a data defaulting framework to demonstrate this. Here, we will create a table and a form that allows us to store defaults for a table, and a class that will set the defaults when a record is created.
Getting ready...
We will need a settings form and table, along with a table for which we shall set the defaults for. This example will use the sample vehicle management solution developed during the course of this book.
How to do it...
First, we will create the settings table for the fields that we want to allow defaults for. To do so, follow these steps:
- Create a new table named
ConWHSVehicleTableDefaults
.
Note
This particular sample will be fixed to the vehicle table, but...