Reading Notes through code

If you ever had to read the notes blob in the Record Link table, you might have noticed that it contains some strange characters. This makes it hard to use anywhere without some handling.

This is because NAV uses .NET BinaryWriter and writes the length of the string in it.
If you look around the internet, you will find some code to actually do the writing. Some with .net dll’s, other with plain NAV code (

When you look to read the data, not much is found. And if you do find something, mostly external dll’s are used. So I took a bit of time to translate this into C/AL code.
Start by creating a new function which accepts 1 parameter and returns 1 variable:- Input: VAR RecordLink => Record “Record Link”
– Output: Text 1024

Also create the following variables locally:
– BinaryReader => DotNet ‘mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.IO.BinaryReader
– MemoryStream => DotNet ‘mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.IO.MemoryStream
– InStream => InStream

Now you are basically halfway of reading the note string…
All that is left, is to make our function return the value which is done with the code below:




MemoryStream := MemoryStream.MemoryStream;
MemoryStream := Instream;

BinaryReader := BinaryReader.BinaryReader(MemoryStream);


There you go, really easy.
You will see that I am using a MemoryStream Object, that is because the BinaryReader will not accept the Instream as a variable, where according to the link to write, the BinaryWriter DOES accept the OutStream.

My code only reads the first 1024 characters. But I assume most of you are proficient enough to edit the code and read the note into an array, or use multiple functions to read the rest of the data.

Anyway, enjoy the code 🙂

Don’t forget that since this is using DotNet variables, it will only work through RTC. But it will also work for printing notes in RDLC Reports.

6 thoughts on “Reading Notes through code

  1. Pingback: Reading Notes through code |

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.