'Document no' in General Journal not increment

raja123raja123 Member Posts: 49
I'm trying to insert 100 general lines in general journal, but the documnet no is not increment

here's my code


Integer - OnPreDataItem()

Integer.SETRANGE(Number,1,10);
GenJournalLine.SETRANGE("Journal Batch Name",'DEFAULT');
GenJournalLine.SETRANGE("Journal Template Name",'GENERAL');
IF GenJournalLine.FINDLAST THEN
Line:=GenJournalLine."Line No.";


Integer - OnAfterGetRecord()

GenJournalLine.INIT;
GenJournalLine."Journal Batch Name":='DEFAULT';
GenJournalLine."Journal Template Name":='GENERAL';
Line:=Line+10000;
GenJournalLine."Line No.":=Line;
GenJournalLine."Posting Date":=022819D;
GenJournalLine."Document Type":=GenJournalLine."Document Type"::Payment;
//GenJournalLine."Document No.":=GenJournalLine."Document No.";
GenJournalLine."Account Type":=GenJournalLine."Account Type"::"G/L Account";
GenJournalLine."Account No.":='11200';

GenJournalLine.VALIDATE("Account No.",'11200');
GenJournalLine.INSERT(TRUE);

Best Answer

Answers

  • AlexeyShaminAlexeyShamin Member Posts: 7
    edited 2019-05-15
    Hello! you should use SetUpNewLine function in 81 table
  • raja123raja123 Member Posts: 49
    Hey AlexeyShamin,

    Do you want me to call that function??
    Can you explain in detail.
  • raja123raja123 Member Posts: 49
    Hello! you should use SetUpNewLine function in 81 table
    Can you explain in detail.
  • raja123raja123 Member Posts: 49
    Try this one:

    Integer.SETRANGE(Number,1,10);
    LastGenJournalLine.SETRANGE("Journal Batch Name",'DEFAULT');
    LastGenJournalLine.SETRANGE("Journal Template Name",'GENERAL');
    IF LastGenJournalLine.FINDLAST THEN
    Line:=LastGenJournalLine."Line No.";

    Integer - OnAfterGetRecord()

    GenJournalLine.INIT;
    GenJournalLine."Journal Batch Name":='DEFAULT';
    GenJournalLine."Journal Template Name":='GENERAL';
    Line:=Line+10000;
    GenJournalLine."Line No.":=Line;

    GenJournalLine.SetUpNewLine(LastGenJournalLine, 0, TRUE);

    GenJournalLine."Posting Date":=022819D;
    GenJournalLine."Document Type":=GenJournalLine."Document Type"::Payment;
    //GenJournalLine."Document No.":=GenJournalLine."Document No.";
    GenJournalLine."Account Type":=GenJournalLine."Account Type"::"G/L Account";
    GenJournalLine."Account No.":='11200';

    GenJournalLine.VALIDATE("Account No.",'11200');
    GenJournalLine.INSERT(TRUE);

    LastGenJournalLine := GenJournalLine;

    9i4mgp7cz9n7.png
    I'm getting this error
  • krikikriki Member, Moderator Posts: 8,902
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
    NAV TechDays 2020: 19 & 20 November 2020, Antwerp (Belgium)
  • raja123raja123 Member Posts: 49
    Try this one:

    Integer.SETRANGE(Number,1,10);
    LastGenJournalLine.SETRANGE("Journal Batch Name",'DEFAULT');
    LastGenJournalLine.SETRANGE("Journal Template Name",'GENERAL');
    IF LastGenJournalLine.FINDLAST THEN
    Line:=LastGenJournalLine."Line No.";

    Integer - OnAfterGetRecord()

    GenJournalLine.INIT;
    GenJournalLine."Journal Batch Name":='DEFAULT';
    GenJournalLine."Journal Template Name":='GENERAL';
    Line:=Line+10000;
    GenJournalLine."Line No.":=Line;

    GenJournalLine.SetUpNewLine(LastGenJournalLine, 0, TRUE);

    GenJournalLine."Posting Date":=022819D;
    GenJournalLine."Document Type":=GenJournalLine."Document Type"::Payment;
    //GenJournalLine."Document No.":=GenJournalLine."Document No.";
    GenJournalLine."Account Type":=GenJournalLine."Account Type"::"G/L Account";
    GenJournalLine."Account No.":='11200';

    GenJournalLine.VALIDATE("Account No.",'11200');
    GenJournalLine.INSERT(TRUE);

    LastGenJournalLine := GenJournalLine;

    Thnak you AlexeyShamin
Sign In or Register to comment.