D365 Business CentralSteps to create Table Extension Object and Page Extension Object Using Visual Studio Code in NAV
Table Extension and Page Extension are two new objects introduced in the Microsoft Dynamics NAV TENERIFE Developer Preview (Visual Studio Code) release. Table Extension allows to add more fields to an existing table and to change properties of certain fields of a table. Page Extension object allows to add additional fields and actions to an existing page and extends Dynamics NAV page object.
This article will provide the basic steps to create a Table extension object and Page extension object using Visual Studio Code in NAV.
1. Visual Studio Code
2. Microsoft Dynamics NAV TENERIFE (Developer Preview)
To create a table extension object and page extension object using Visual Studio Code in NAV. To demonstrate this, I will be adding an additional field on Item card.
- Create a new folder for a new project.
- Open this folder in Visual Studio Code
- Create a new file within this folder in Visual Studio Code
- Let’s name this file ‘ItemTableExt.al’
- Typing the shortcut ‘ttableext’ will create the basic layout for a table extension.Fig 3: Shortcut ttableextFig 4: Basic layout of a table extension
Replace ‘id’ with a unique table id. It should be in the range from ‘70000000’ to ‘74999999’. Replace ‘MyExtension’ with a unique name of the table extension and ‘MyTargetTable’ with the name of the table where these additional fields have to be added.
This is shown in the below Screenshot.
After entering the ‘MyTargetTable’ name, Press ‘Ctrl+Shift+B’ to build the solution which will create app.json file.
- Here, I will be creating a Decimal Field ‘Control Sample Qty’. To create a table field, type the shortcut ‘tfield’.
- Replace ‘id’ with a unique field id. Replace ‘MyField’ with a unique field name and mention the type of the field viz. Decimal, Integer, etc. Mention the properties of the field below.Fig 6: New field ‘Control Sample Qty’ with ID ‘70000000’ of type ‘Decimal’ is added to ‘Item table’ which is highlighted in red colour. Property of this field i.e. ‘Editable=False’ is highlighted in lime colour.
Hence the table extension has been created.
- To create a page extension, create a new file. Let’s name this file as ItemPageExt.al.
- Type the shortcut ‘tpageext’ to create a basic layout of a page extension.Fig 7: Basic layout of a page extension.
In the layout section, you can use the following functions to place page fields and groups on the page. Similarly, in the actions section, you use these functions to place actions in the ribbon. (Note: General and AddressDetails are group names)
- addfirst(General) – Applies to Groups only
- addlast(General) – Applies to Groups only
- addafter(AddressDetails) – Applies to Fields and groups
- addbefore(AddressDetails) – Applies to Fields and groups
- movefirst(General) – Applies to Groups only
- movelast(General) – Applies to Groups only
- moveafter(AddressDetails) – Applies to Fields and groups
- movebefore(AddressDetails) – Applies to Fields and groups
- Replace id with a unique page extension id in the range from ‘70000000’ to ‘74999999’. Replace ‘MyExtension’ with the name of the page extension. Replace ‘MyTargetPage’ with the name of the existing page in which additional functionality has to be added.
- The following page extension extends Item card and adds field ‘Control Sample Qty’ to the ‘InventoryGrp’.Fig 8: Field is added to the page using Page extension
Hence, page extension is created.
- Build the solution using ‘Ctrl+Shift+B’.
Hence ‘navx file’ will be created.
- Press F5 to create launch.json file or manually create launch.json file. Thus launch.json will be created.Fig: launch.json
- In the NAV Web client, in Extensions Management, the published extension will be displayed.Fig 9: Extensions Management
Thus, the newly created field i.e. ‘Control Sample Qty’ will be displayed in Item card.Fig 10: New field ‘Control Sample Qty’ field has been added to Item card.
Thus, Table extension is used when additional fields are to be added to an existing table or any properties of the fields have to be changed and Page extension is used to add additional functionality to existing pages like extra fields and actions.