Return multiple text lines into report

I am trying to use the "FIND" command to retrieve multiple comment lines, but I can only seem to get the first record:


CLEAR(Comment_Line);
Comment_Line.SETFILTER("No.", "Service Shipment Header"."Order No.");
Comment_Line.SETRANGE(Type,2);
IF Comment_Line.FIND('-') THEN BEGIN
Fault_1 := Comment_Line.Comment;
REPEAT
UNTIL Comment_Line.NEXT = 0;
END;

Is this the wrong use of the command, or am I misssing something?

As always, thank you for at least reading this.
Krakmup

Answers

  • amaama Member Posts: 15
    Find('-') should give you a set where as FINDFIRST will only get you the single record.

    Try FINDSET instead to guarantee based on your version of NAV that it's working. But i'd guess your filters are bad.
    Try settings the filters directly on the NAV table as well if you are confused.
  • manthonylugomanthonylugo Member Posts: 46
    edited 2017-08-18
    Comment_Line.RESET;
    Comment_Line.SETFILTER("No.", "Service Shipment Header"."Order No.");
    Comment_Line.SETRANGE(Type,Comment_Line.Type::"2");
    IF Comment_Line.FIND('-') THEN BEGIN
    REPEAT
    IF Fault_1 = '' THEN
    Fault_1 := Comment_Line.Comment
    ELSE
    Fault_1 += Fault_1 + ' ' + Comment_Line.Comment;
    UNTIL Comment_Line.NEXT = 0;
    END;
  • David_SingletonDavid_Singleton Member Posts: 5,479
    edited 2017-08-20
    ...

    IF Comment_Line.FIND('-') THEN BEGIN
    REPEAT
    IF Fault_1 = '' THEN
    Fault_1 := Comment_Line.Comment
    ELSE
    Fault_1 += Fault_1 + ' ' + Comment_Line.Comment;
    UNTIL Comment_Line.NEXT = 0;
    END;

    I think (of course we are all just guessing) that what is needed is:
    WITH Comment_Line DO BEGIN
    RESET;
    SETRANGE("No.", "Service Shipment Header"."Order No.");
    SETRANGE(Type,Type::"2");
    IF FINDSET THEN BEGIN
    i := 1;
    REPEAT
      Fault[i] := Comment
      i += 1;
    UNTIL (NEXT = 0) or (i >= ARRAYLEN(Fault));
    END;
    
    David Singleton
Sign In or Register to comment.