How To: Use the Dictionary, RecordID, RecordRef, and BigText Data Types in AL Programming for Dynamics Business Central On Premises
There are many data types that are used in the AL programming language, used to modify code in 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 consists 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.
Figure 1 – Creating a procedure by using a snippet in Dynamics Business Central on premises
In Figure 1, we are trying to store the customer name of that specific ID.
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 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 record
Syntax: No: = RecordRef.Number()
Name Method: Identify the name of record
Syntax: Name := RecordRef.Name()
Record ID contains the table number and the 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 table no.
Figure 2 – RecordID & RecordRef data types in Dynamics Business Central on premises
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])
Figure 3 –BigText data types in Dynamics Business Central on premises
If you have any questions about this or other Dynamics NAV or Business Central topic for any version, contact ArcherPoint.
Read more "How To" blogs from ArcherPoint for practical advice on using Microsoft Dynamics Business Central or NAV.
If you are interested in NAV/Business Central development, check out our collection of NAV Development Blogs.