Skip to main content

Notifications

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.

  • Verified answer
    YUN ZHU Profile Picture
    81,693 Super User 2025 Season 1 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

  • 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

  • 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 ,

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,021 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

    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,021 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.

  • Suggested answer
    pankaj.k Profile Picture
    974 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
    pankaj.k Profile Picture
    974 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
    Manan_Shah Profile Picture
    1,457 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

  • Verified answer
    DAnny3211 Profile Picture
    9,276 Moderator 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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,217 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,978 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans