As you can only have a maximum length of 250 characters for a text field in NAV tables, it is often the need to store longer text related to a record.
I also wrote about a workaround to something related to this, you can find the post here: Extended Comments in NAV
Another possibility is to use a BLOB field. I used it also in this post to attach files to records. (even if in that case it is better to use the built in NAV datatypes Media and MediaSet.)
For showing the concept, I created a test table(with a BLOB field) and two pages: one list page with the records and one StandardDialog page with a Text field based on a global variable (unlimited text).
On the List page I wrote code in trigger OnDrillDown of the BLOB field to read data from it, open the StandardDialog page to enter or change the text and then, if the text was modified, to write the new text into the BLOB field:
Description - OnDrillDown() CALCFIELDS(Description); Description.CREATEINSTREAM(InStr); BinaryReader := BinaryReader.BinaryReader(InStr,Encoding.UTF8); IF NOT ISNULL(BinaryReader) THEN BEGIN //read value from BLOB field IF BinaryReader.BaseStream.Length > 0 THEN MyText := BinaryReader.ReadString; BinaryReader.Close; END; InputLongTextTest.SetText(MyText); IF InputLongTextTest.RUNMODAL = ACTION::OK THEN BEGIN NewText := InputLongTextTest.GetText; IF NewText <> MyText THEN BEGIN //write value to BLOB field CLEAR(Description); Description.CREATEOUTSTREAM(OutStr); BinaryWriter := BinaryWriter.BinaryWriter(OutStr,Encoding.UTF8); BinaryWriter.Write(NewText); BinaryWriter.Close; MODIFY; END; END;
And in the StandardDialog page there is code (two global functions) only to get/set the text global variable:
SetText(pMyText : Text) MyText := pMyText; GetText() : Text EXIT(MyText);
This is only a small example of how you can read and write from/to a BLOB field from a technical perspective. It is not ready to use functionality, but you can use the example to build what you need based on it. I wonder though how can we do this in AL Extensions v2, without dot net interop…
I also found an interesting post for reading/writing images to BLOB field, you can read it here:
Binary data with NAV Web Service
You can also download the sample objects used in my example from GitHub
file name: ReadWriteTextBlobNavSampleFilesCAL.txt