'Document no' in General Journal not increment

raja123raja123 Posts: 41Member
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 Posts: 7Member
    edited 2019-05-15
    Hello! you should use SetUpNewLine function in 81 table
  • raja123raja123 Posts: 41Member
    Hey AlexeyShamin,

    Do you want me to call that function??
    Can you explain in detail.
  • raja123raja123 Posts: 41Member
    Hello! you should use SetUpNewLine function in 81 table
    Can you explain in detail.
  • raja123raja123 Posts: 41Member
    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 Posts: 8,737Member, Moderator
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
    NAV TechDays 2019: 21 & 22 November 2019, Antwerp (Belgium)
  • raja123raja123 Posts: 41Member
    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.