Hi
to start with development for Microsoft Dynamics first we need to learn some basics so today I will show you what are the main table components, what are table properties, with which triggers table work, what are the fields in table and what triggers fields have.
So for the beginning we need to define what is table. Table is Microsoft Dynamics NAV object where the records are stored. Every table contain table properties, triggers, fields, keys.
Table properties
To access table properties we need to open Object Designer and then choose Table in object designer and for this blog post we will show table properties on Vendor table. To see table properties select Vendor and then click on Design (Alt + d).
Picture 1. Access to the Vendor table designer
Then the Table Designer will open and we will see all the fields on the table. But for now we need to find table properties and we will do this by clicking on the first empty row and go to View – Properties or press Shift + F4 and we will get Table Properties window.
Picture 2. Table properties
Now I will explain each of this property:
- ID – number of the table
- Name – Name of the table, it is used internally when developers work with tables
- Caption – Name of the table that will show in RTC
- CaptionML – describe multilanguage caption for the table
- Description – description of the table
- DataPerCompany – this allow us to define is the data in the table shared with other companies or it is used only for this company.
- Permissions – grant users of this table level of access to table data in other table.
- LookupPageID – define which page is for looking data in this table
- DrillDownPageID – specify page ID that is used to drill down information in table
- DataCaptionFields – specify fields that will show like a part of the caption
- PasteIsValid – allow users to paste data into the table
- LinkedObject – allow users to link table to SQL server object.
Table triggers
Similar to the databases, triggers are used when we want to predefined functions that will start on certain events happen.
To show table triggers we need to be in Table Designer on last row, and then go to View – C/AL code or press F9 button.
There are five table triggers that will be explained in next few bullets:
- Documentation – all text and code that we enter in this trigger will not be executed. It’s usually used for documenting changes in object.
- OnInsert () – code in this trigger is executed when a new record will be inserted into the table.
- OnModify() – code in this trigger is executed when a record in table is modified.
- OnDelete() – executed before a record will be deleted from table
- OnRename() – code will be executed if the some part of primary key will be changed because action that change primary key is a rename action.
Table Fields
Every table must have at least one field which have trigger and properties. Depends on what field type you choose you will get another set of properties for the field. Each field can have only one type from 17 available in Microsoft Dynamics NAV 2013 R2.
Picture 3. List of fields in Vendor table
Table field properties will be explained in detail when we will work with tables and use that properties.
To access Table Field Triggers you need to select some field and like for the table triggers go to View – C/AL code or press F9 button.
The C/AL editor for table Vendor will open and you will see two triggers for every field:
- OnValidate() – C/AL code is executed when user create an entry.
- OnLookup() – this trigger is executed when user click on lookup field.
Picture 4. Example of the Contact field trigger on Vendor table
Thanks for reading, next time I will show you keys, table relations, some special fields and in the end we will create our first table.
Cheers,
Renato