Field properties
The specific properties that can be defined for a field depend on the data type. There are a minimum set of unpersal properties. We will review those first. Then we will review the rest of the more frequently used properties, some that are data dependent and some that are not. Check out the remaining properties by using Developer and IT Pro Help from within the table designer.
We can access the properties of a field while viewing the table in the Design mode, highlighting the field, and then clicking on the Properties icon, clicking on View | Properties, or pressing Shift + F4. All the property screenshots in this section were obtained this way for fields within the standard Customer table. As we review various field properties, you will learn more if you follow along in your NAV system using the Object Designer. Explore different properties and the values they can have. Use NAV 2017's Help functions liberally for additional information and examples.
The property value which is enclosed in < > (less than and greater than brackets) is the default value for that property. When we set a property to any other value, < > should not be present unless they are supposed to be a part of the property value (for example, as part of a Text string value). When a property has been changed from its default value, the NAV 2017 C/AL Editor displays the new property value in bold font.
All the fields, of any data type, have the following properties:
- Field No.: The identifier for the field within the containing table object.
- Name: The label by which C/AL code references the field. A name can consist of up to 30 characters, including special characters. The name can be changed by a developer at any time and NAV will automatically ripple that change throughout the system. If no Caption value has been defined, the name is used as the default caption when data from this field is displayed. Changing names that are used as literals in C/AL code can cause problems with some functions, such as web services and GETFILTERS where the reference is based on the field name rather than the field number.
- Caption: This contains the defined caption for the currently selected language. It will always be one of the defined multi-language captions. The default language for a NAV installation is determined by the combination of a set of built-in rules and the languages available in a specific installation of the software.
- CaptionML: This defines the multi-language caption for the table. It also identifies the language in use, for example ENU for US English (as seen in the following screenshot).
- Description: This is an optional use property, for our internal documentation.
- Data Type: This defines what type of data format applies to this field (for example, Integer, Date, Code, Text, Decimal, Option, Boolean).
- Enabled: This determines whether or not the field is actpated for user generated events. The property defaults to <Yes> and is rarely changed.
- AccessByPermission: Determines the permission mask required for a user to access this field in Pages or in the user interface (UI).
The following screenshot shows the properties for the Picture field of Data Type BLOB in the Company Information table (this field is often used to store a company logo):
The set of properties shown for a BLOB data type field is the simplest set of field properties. After the properties that are shared by all the data types, the BLOB-specific properties are shown:
- SubType: Defines the type of data stored in the BLOB and sets a filter in the import/export function for the field. The three sub-type choices are Bitmap (for bitmap graphics), Memo (for text data), and User-Defined (for anything else). User-Defined is the default value.
- Owner: Defines the NAV Server user who owns the object in the BLOB field.
- Compressed: This defines whether the data stored in the BLOB field is stored in a compressed format. If we want to access the BLOB data with an external tool (from outside NAV), this property must be set to <No>.
The properties of Code and Text data type fields are quite similar to one another. This is logical since both represent types of textual data. The following screenshots are from the Customer table:
The following are some common properties between the Code and Text data types:
- DataLength: This specifies the maximum number of characters the field can contain. This is 250 characters in a table, but if no maximum is specified for a Text field, there is no length limitation for a variable stored only in memory (working storage). Code fields in memory cannot exceed 1,024 characters in length.
- InitValue: This is the value that the system will supply as a default when the field is initialized.
- CaptionClass: This can be set up by the developer to allow users to dynamically change the caption for a textbox or a checkbox. CaptionClass defaults to empty. For more information, refer to Developer and IT Pro Help. It is used in base NAV in the Dimensions fields.
- Editable: This is set to <No> when we don't want to allow a field to be edited, for example, if it is a computed or assigned value field that the user should not change. Editable defaults to <Yes>.
- NotBlank, Numeric, CharAllowed, DateFormula, and ValuesAllowed: Each of these allows us to place constraints on the data that can be entered into this field by a user. They do not affect data updates drpen by application C/AL code.
- SQL Data Type: This applies to the Code fields only. SQL Data Type defines what data type will be allowed in this particular Code field and how it will be mapped to a SQL Server data type. This controls sorting and display. Options are Varchar, Integer, BigInteger or Variant. Varchar is the default and causes all the data to be treated as text. Integer and BigInteger allow only numeric data to be entered. A Variant can contain any of a wide range of NAV data types. In general, once set, this property should not be changed. These settings should not affect data handling done in SQL Server external to NAV, but the conservatpe approach is not to make changes here.
- TableRelation: This is used to specify a relationship to data in the specified target table. The target table field must be in the primary key. The relationship can be conditional and/or filtered. The relationship can be used for validation, lookups, and data-change propagation.
- ValidateTableRelation: If a TableRelation field is specified, set this to <Yes> in order to validate the relation when data is entered or changed (in other words, confirm that the entered data exists in the target table). If a TableRelation field is defined and this property is set to <No>, the automatic table referential integrity will not be maintained. Caution: application code can be written that will bypass this validation.
- TestTableRelation: A property left over from earlier versions which no longer has use or value.
- ExtendedDataType: This property allows the optional designation of an extended data type which automatically recepes special formatting and validation. Type options include an e-mail address, a URL, a phone number, report filter, progress bar ratio, or a masked entry (as dots). An action icon may also be displayed as shown in the following screenshot, where there are three fields with ExtendedDataType defined:
Let's take a look at the properties of two more data types, Decimal and Integer, especially those properties related to numeric content:
- DecimalPlaces: This sets the minimum and maximum number of decimal places (min:max) for storage and display in a Decimal data item. Default is 2 (2:2), the minimum is 0, and the maximum is 255.
- BlankNumbers, BlankZero, and SignDisplacement: These can be used to control the formatting and display of the data field on a page. BlankNumbers and BlankZero means that all fields of the chosen values are to be displayed as blank. SignDisplacement allows data positioning to be shifted for negatpe values.
- MinValue and MaxValue: When set, these constrain the range of data values allowed for user entry. The range available depends on the field data type.
- AutoIncrement: This allows for the definition of one Integer field in a table to automatically increment for each record entered. When used, which is not often, it is almost always to support the automatic updating of a field used as the last field in a primary key, enabling the creation of a unique key. Use of this feature does not ensure a contiguous number sequence. When the property is set to <Yes>, the automatic functionality should not be overridden in code:
The properties for an Option data type are similar to those of other numeric data types. This is reasonable because an Option is stored as an integer, but there are also Option specific properties:
- OptionString: Details the text interpretations for each of the stored integer values contained in an Option field
- OptionCaption and OptionCaptionML: These serve the same captioning and multi-language purposes as caption properties for other data types
Internally, options are stored as integers tied to each option's position in the OptionString property, starting with position 0, 1, 2, and so on. OptionString and OptionCaption are shown in the following screenshot: