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.
Before I start, I must say I first read about this on the following Kauffmann’s blog entry. So all kudos to him 🙂 When I read it I found it really interesting and used it on some of the tools we use internally. So this post will be pretty much my experience with what Kauffmann knowledge 🙂
As developers in an ever more repeatable world we should strive to write code in ways that make it as flexible and generic as we possibly can. A trick I use is too pass things around in ever more generic ways by using Variants.
A good example can be seen below where the function ReturnRecordIDasText function takes either a Record or a RecordRef as input and then returns the RECORDID as text.
In NAV 2013 R2, if a RecordRef does not have a active record, CURRENTKEYINDEX will return -1. IN NAV2009 and older, the value was 1 (As the number of the primary key).
If the value of CURRENTKEYINDEX is given to KEYINDEX – a index out of bounds error will occur.
This is not documented in the NAV 2013 R2 help.
Recently, one of our client started getting error “The length of the source exceeds the size of the destination buffer” when trying to export text file using code (not using dataport). They were exporting file daily since many years and objects also not modified since long time but suddenly they started getting this error message.