web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

The Length of the string is 1188 but it must be less than or equal to 1024

(0) ShareShare
ReportReport
Posted on by

I am trying to import a txt file and iam getting this error: The Length of the string is 1188 but it must be less than or equal to 1024

the field is of text and i have mentioned the size to [2000] but still shows this error!!

Any sugestion to solve this issue.

I have the same question (0)
  • Verified answer
    DAnny3211 Profile Picture
    11,389 on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    hi

    but your string variable is how long?

    my guess is that you have some text variable set to 1024

    can you share the code?

    DAniele

  • Suggested answer
    Manan_Shah Profile Picture
    1,459 on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    Hi,

    Please below attach link.

    https://learn.microsoft.com/en-us/business-applications-release-notes/april19/dynamics365-business-central/max-length-of-variable-length-table-fields-has-been-expanded


    Many Thanks,
    Manan

  • Suggested answer
    pankaj.k Profile Picture
    994 on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    Hi Zayn

    As per the Code and Text Data Type you can use Maximum :1024 Length.

    I suggest you create one more field so you can add more Data.

    Note: As per the Microsoft document they are working for the Code & Text Length 2048 but we don't have any idea when we get this new changes.

    https://learn.microsoft.com/en-us/business-applications-release-notes/april19/dynamics365-business-central/max-length-of-variable-length-table-fields-has-been-expanded

  • Suggested answer
    pankaj.k Profile Picture
    994 on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    hi Sainudheen 


    As suggest my above Answer if you create 2 Field then also need to use CopyStr function so you can copy data as per length.

    For CopyStr function check  URL: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-copystr-method 

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,057 Moderator on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    The best idea here would be to write the long text into a blob field instead of using a text variable or a text field.

    Maybe also a good idea to try to share your code, then it will be easier to assist you.

  • Community Member Profile Picture
    on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    Thanks for the all the replies Now, iam trying to make my field into a blob data type and iam using standard method like how  work description works ,by creating two procedures

    in the table,

    procedure SetWorkDescription(newfield: Text)

       var

           OutStream: OutStream;

       begin

           Clear("myfield");

           "INTRA_NAME".CreateOutStream(OutStream, TEXTENCODING::UTF8);

           OutStream.WriteText(newfield);

           Modify();

       end;

       procedure GetWorkDescription() mynewfield: Text

       var

           TypeHelper: Codeunit "Type Helper";

           InStream: InStream;

       begin

            CalcFields("myfield");

           "INTRA_NAME".CreateInStream(InStream, TEXTENCODING::UTF8);

           exit(TypeHelper.TryReadAsTextWithSepAndFieldErrMsg(InStream, TypeHelper.LFSeparator(), FieldName("myfield")));

       end;

    here what happens is iam trying add the code into the xmlport and on

     trigger OnAfterGetRecord()

                   var

                   begin

                       myfield := GetWorkDescription()

                   end;

    but it shows error you cannot use your The name 'GetWorkDescription' does not exist in the current context, so iam really stuck now...

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,057 Moderator on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    Can you please share the complete object?

    Use rich formatting there is a function for inserting code.

  • Community Member Profile Picture
    on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024
    xmlport 50000 "Import"

    {
        Format = VariableText;
        Direction = Import;
        FieldDelimiter = '^';
        FieldSeparator = '§';
        TextEncoding = MSDOS;
        schema
        {
            textelement(Root)
            {
                tableelement(mytable; mytable)
                {

                    fieldelement(myfield; mytable.myfield)
                    {

                    }
                    trigger OnAfterGetRecord()
                    begin
                        mytable.myfield := Getnewfieldblob()
                    end;
                }

            }

        }
    }
    table 50011 MyTable
    {
        DataClassification = ToBeClassified;

        fields
        {
            field(1; MyField; blob)
            {
                DataClassification = ToBeClassified;

            }
        }

        procedure Setnewfieldblob(Newfield: Text)
        var
            OutStream: OutStream;
        begin
            Clear("MyField");
            "MyField".CreateOutStream(OutStream, TEXTENCODING::UTF8);
            OutStream.WriteText(Newfield);
            Modify();
        end;

        procedure Getnewfieldblob() new: Text
        var
            TypeHelper: Codeunit "Type Helper";
            InStream: InStream;
        begin
            CalcFields("MyField");
            "MyField".CreateInStream(InStream, TEXTENCODING::UTF8);
            exit(TypeHelper.TryReadAsTextWithSepAndFieldErrMsg(InStream, TypeHelper.LFSeparator(), FieldName("MyField")));
        end;



    }


    This is my code ,

  • Community Member Profile Picture
    on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    here is my code  NorthW

  • Verified answer
    YUN ZHU Profile Picture
    93,654 Super User 2025 Season 2 on at
    RE: The Length of the string is 1188 but it must be less than or equal to 1024

    Hi, I have done a similar process before, but when exporting, I hope it can give you some reference.

    https://yzhums.com/31902/

    Thanks.

    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,106

#2
YUN ZHU Profile Picture

YUN ZHU 1,752 Super User 2025 Season 2

#3
OussamaSabbouh Profile Picture

OussamaSabbouh 1,670

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans