Creating and modifying tables
In Chapter 1, Introduction to NAV 2017, we created the Radio Show table for the WDTU application. At that time, we used the minimum fields that allowed us to usefully define a master record. Now let's set properties on existing data fields, add more data fields, and create an additional data table to which the Radio Show table can refer.
Our new data fields are shown in the following layout table:
After we have completed our Radio Show table, it will look like this:
Next, we need to fill the OptionString and Caption properties for the Option field Frequency. Highlight the Frequency field, then click on the Properties icon or press Shift + F4. Enter values for the OptionString property, as shown in the next screenshot; don't forget to allow the leading space followed by a comma to get a space/blank as the first option. Be sure to copy and paste the same information to the OptionCaption property. The OptionCaptionML property will fill in automatically with a copy of that information (since we do not have a second language installed). Notice that the properties that have been changed from the default are displayed in bold. This new feature makes it much easier for developers to see what properties have been modified:
Next, we want to define the reference table we are going to tie to the Type field. The table will contain a list of the available Radio Show Types such as Music, Talk, Sports, and so on. We will keep this table very simple, with Code as the unique key field and Description as the text field. Both fields will be of the default length as shown in the following layout. Create the new table and save it as Table 50001 with the name of Radio Show Type:
Before we can use this table as a reference from the Radio Station table, we need to create a list page that will be used both for data entry and data selection for the table. We will use Page Designer and the Page Wizard to create a list page. We should be able to do this pretty quickly. Click on Pages, click on the New button, enter 50001 in the Table field (the table field will redisplay the table name), then choose the Wizard to create a page type of List:
Populate the page with both (all) the fields from the Radio Show Type table. Our designed page should look like the following screenshot:
Save the page as number 50002, exit the Page Designer, and name the page Radio Show Types. Test the page by highlighting it in the Object Designer and then clicking on the Run button. The new page will be displayed. While the page is open, enter some data (by clicking on New) like the examples shown in the following screenshot:
Now we'll return to the Radio Show Type table and set the table's properties for LookupPageID and DrillDownPageID to point to the new page we have just created. As a reminder, we will use Design to open the table definition, then focus on the empty line below the Description field, and either click on the properties icon or press Shift + F4. In the values for each of the two PageID properties, we can either enter the page name (Radio Show Types) or the page number (50002). Either entry will work, but as you can see in the following screenshot, the appearance depends on what you enter:
After the table has been saved, the next time we view those two PageID properties, they look like this: