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 :
Microsoft Dynamics NAV (Archived)

How to write the CAL Code For Splitting Comments

(0) ShareShare
ReportReport
Posted on by 246

Hi experts,

 i want split  Bulk  Comment  text  with equally length  and if the splitting  happen in between word  this should not accure ,this word come on to the next line and if you have any  new lines  with only space in  the  Bulk Text these should also inlude in comment sheet.Could you help me.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Suresh Kulla Profile Picture
    50,237 Super User 2025 Season 2 on at
    RE: How to write the CAL Code For Splitting Comments

    Check this function

    PROCEDURE SplitComments@1240060000(CommentText@1240060000 : Text);

       VAR

         SpaceLeft@1240060001 : Integer;

         Word@1240060002 : Text;

         CommentLine@1240060003 : Record 44;

         LineNo@1240060004 : Integer;

         TempWord@1240060005 : Text[50];

         Pos@1240060006 : Integer;

       BEGIN

         CommentLine.RESET;

         CommentLine.SETRANGE("Document Type","Document Type");

         CommentLine.SETRANGE("No.","No.");

         CommentLine.SETRANGE("Document Line No.","Document Line No.");

         IF CommentLine.FINDLAST THEN

           LineNo := CommentLine."Line No.";

         CommentLine.INIT;

         CommentLine."Document Type" := "Document Type";

         CommentLine."No." := "No.";

         CommentLine.Date := TODAY;

         CommentLine."Document Line No." := "Document Line No.";

         CommentLine.Code := COPYSTR(USERID,1,10);

         SpaceLeft := MAXSTRLEN(CommentLine.Comment);

         WHILE STRLEN(CommentText) > 0 DO BEGIN

            Pos := STRPOS(CommentText,' ');

            IF Pos > 50 THEN

              Pos := 50 - 1;

            IF Pos > 0 THEN BEGIN

              Word := COPYSTR(CommentText, 1, Pos);

              CommentText := COPYSTR(CommentText, Pos + 1);

            END ELSE BEGIN

              IF STRLEN(CommentText) >= 50 THEN BEGIN

                Word := COPYSTR(CommentText, 1, 50 - 1);

                Comment := COPYSTR(CommentText, 50);

              END ELSE BEGIN

                Word := CommentText;

                CLEAR(CommentText);

              END;

            END;

           IF (STRLEN(Word) > SpaceLeft) THEN BEGIN

             LineNo += 10000;

             CommentLine."Line No." := LineNo;

             CommentLine.INSERT(TRUE);

             CommentLine.Comment := '';

           END;

           TempWord := COPYSTR(Word, 1);

           CommentLine.VALIDATE(Comment,CommentLine.Comment + TempWord);

           SpaceLeft := 50 - STRLEN(CommentLine.Comment);

           IF STRLEN(CommentText) = 0 THEN BEGIN

             LineNo += 10000;

             CommentLine."Line No." := LineNo;

             CommentLine.INSERT(TRUE);

           END;

         END;

       END;

    I have added this in Sales Comment Sheet Page to copy a large text into multiple text lines on the sales comment line.

  • Verified answer
    Binesh Profile Picture
    7,885 on at
    RE: How to write the CAL Code For Splitting Comments

    Hello Suresh,

    Here is a nice article that are i used my production, you can go.

    How Do I Split Comments or Copy from somewhere and paste in comments

  • Mark Landman Profile Picture
    65 on at
    RE: How to write the CAL Code For Splitting Comments

    Thanx it works great!

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#2
SC666 Profile Picture

SC666 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans