I need to add a comment into the purchase order comment table.
How can I amend the current code so it finds the last line no and then adds 1000 to it to allow a new entry?
IF QuantityChange THEN BEGIN
IF Purchheader."Released Once" THEN BEGIN
IF recPurchLine.Quantity <> xRec.Quantity THEN BEGIN
recPurchCommentLine.RESET;
recPurchCommentLine.SETRANGE("Document Type",recPurchLine."Document Type");
recPurchCommentLine.SETRANGE("No.", recPurchLine."Document No.");
DO SOMETHING HERE FOR THE LINE NO.
recPurchCommentLine."Comment Type" := recPurchCommentLine."Comment Type"::PurchChange;
recPurchCommentLine.Comment :=
STRSUBSTNO(
Text107,
recPurchLine."Line No.",
xRec.Quantity,
recPurchLine.Quantity);
recPurchCommentLine.Date := WORKDATE;
recPurchCommentLine.INSERT(TRUE);
END;
END;
END ELSE
0
Answers
Use recPurchCommentLine.FINDLAST to find the last record. Then you shall increment the line no. by 10000 using recPurchCommentLine."Line No." + 10000;