Large Text field in Page Extension

Hi,

I’m trying to add a large Text[] field to a table extension in Business Central v13.0

The Text field should display a “large” multi-line text box in the UI where the user could type text.

I was able to create a LargeText Variable on a page extension originally and make it multi-line without any issue other than the fact I cannot control the height of the box…

When I decided to add a field to my table so that the data entered in the field could be saved, i ran into an issue. VSCode would only allow me to declare a Text[250] as the largest text field.

How can overcome this?

Can I display a bigger (taller) text box in the modern client?

Would blob be my next avenue and convert from blob to text and text to blob so that I am not limited to 250 characters? I need 1000-4000 on average.

Thanks

Yann

AL experience is no different from C/AL in regard of text table fields. FIeld length is limited to 250 symbols, and if you need to store larger values, you have to create a blob field and read it into a Text variable.

This is what I ended up doing.

I created a BLOB field in the database called “Job Description Blob”

field(40001; "Job Description Blob"; Blob) { }

In the page Extension, I created a field that is tied to a variable called “Job Description”

Within the field, I created a OnValidate trigger that calls a procedure called SetJobDescriptionBlobAsText

This takes what you have entered in the textbox field and updates the database.

field("Job Description"; "Job Description")
{
    MultiLine = true;
    Width = 200;

    trigger OnValidate()
    begin
        SetJobDescriptionBlobAsText("Job Description");
    end;
}

The variable called “Job Description” gets created as Text type.

“Job Description”: Text ;

The definition for the SetJobDescriptionBlobAsText looks like this

PROCEDURE SetJobDescriptionBlobAsText("Job Description": Text);
VAR
    TempBlob: Record 99008535 TEMPORARY;
BEGIN
    CLEAR("Job Description Blob");
    IF "Job Description" = '' THEN
        EXIT;
    TempBlob.Blob := "Job Description Blob";
    TempBlob.WriteAsText("Job Description", TEXTENCODING::Windows);
    "Job Description Blob" := TempBlob.Blob;
    MODIFY;
END;

I have created also another Procedure called GetJobDescriptionBlobAsText that reads the database blob and converts it into text.

This fills the text field via the page Trigger called OnAfterGetRecord

procedure GetJobDescriptionBlobAsText(): Text;
VAR
    TempBlob: Record 99008535 TEMPORARY;
    CR: Text[1];
BEGIN
    CALCFIELDS("Job Description Blob");
    IF NOT "Job Description Blob".HASVALUE THEN
        EXIT('');
    CR[1] := 10;
    TempBlob.Blob := "Job Description Blob";
    EXIT(TempBlob.ReadAsText(CR, TEXTENCODING::Windows));
end;

OnAfterGetRecord trigger

trigger OnAfterGetRecord()
begin
"Job Description" := GetJobDescriptionBlobAsText();
end;

And that’s it. I hope this helps anyone trying to do something similar.

I had to do a fair bit of research as I am pretty new to AL.

My next step would be to incorporate a Javascript Addin so that I can control the size of the text box as currently, on the modern client, even though I can type a novel in the textbox, i only ever shows 3 rows at a time.

Thanks again Alexander for the quick reply. Always appreciated.

Yann

There really isn’t a better way to do this? Anyone can help here?