There are many data types that are used in the AL programming language, used to modify code in Microsoft Dynamics Business Central On Premises. This blog explains how to use the Dictionary, RecordID, RecordRef, and BigText data types.
Dictionary Data Type
The Dictionary data type represents a collection of keys and values. Dictionary made of a value and its associated key. Every key in a Dictionary must be unique. Following is an example:
- Create a codeunit using the ‘tcodeunit’ snippet and then provide the ID number and name of the codeunit.
- Create a procedure using the ‘tproceure’ snippet.
The variable mycustomers represents Dictionary data types:
- Each addition to the Dictionary consists of a value and its associated key.
- Every key in a Dictionary must be unique.
- A key cannot be null, but a value can be, only when the value type is a reference type.
In the above scenario, we are storing customer number and name and presenting the name of that specified customer by the Message function.
RecordID & RecordRef
Record Ref references a record in a table. There are many records available; some are presented below:
Number Method: Identify the number of records
Syntax: No: = RecordRef.Number()
Name Method: Identify the name of the record
Syntax: Name := RecordRef.Name()
Record ID contains the table number and primary key of a table. Two instances are there.
Table no() : provides the table number of the table that is identified by the Record ID.
Get Record (): Gets a RecordRef that refers to the record identified by the Record ID.
- Create a codeunit to show an instance.
- Let’s go through an example of the table no.
BigText Data Types
The BigText data type handles large text documents. There are many methods available; three of them presented below.
AddTextMethod : Add text to the string.
Syntax : BigText.AddText(String: String, [Position: Integer])
Length () : Retrieves the length.
Syntax : Length := BigText.Length()
Textposition : Gets the position at which a specific string first occurs in this BigText instance
Syntax : Position := BigText.TextPos(String: String)
GetSubtext : Gets part of a BigText variable
Syntax : [Length := ] BigText.GetSubText(var Variable: BigText, Position: Integer, [Length: Integer])