As we know that we cannot change or customize the tables that already exist in the Dynamics365 Business Central service. To make changes in those Tables we use Table Extension objects.
Table Extension Object helps to create more fields and allows to change some of the properties in an Existing table. By this object, we can store more data in the same table and customize the tables.
Before using this object, we must note that,
- We can use this object to extend Table only if “Extensible Property” set to ‘TRUE’ in that Table.
- System Tables and Virtual Tables cannot be Extended.
- Object’s name length should not be more than 30 characters.
Uses:
- Adding More Fields: We can add more fields in a particular Existing Table and write trigger code for new fields. We can use the ‘OnLookUp’ and ‘OnValidate’ fields to trigger the same as we use in Table.
- Writing new Trigger codes: We can use the same triggers for Table Extensions as we use for Tables. For example, if we need to throw an error before the modification takes place in the existing tables then we can add ‘OnBeforeModify’ Trigger in The Table Extension Object.
- Adding Keys: Just like in the table object, we can define new keys. We can also add keys for new fields added by the Table Extension, if we need to extend keys provided in the existing Table.
- Change of properties: Since Table Object and Table Extensions Object properties are almost the same, so we can add some table properties as we want to customize them.
Table Extension Object Syntax:
tableextension Id MyExtension extends MyTargetTable
{
fields
{
// Add changes to table fields here
}
var
myInt: Integer;
}