'Document no' in General Journal not increment

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

    Do you want me to call that function??
    Can you explain in detail.
  • raja123raja123 Member Posts: 50
    Hello! you should use SetUpNewLine function in 81 table
    Can you explain in detail.
  • raja123raja123 Member Posts: 50
    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: 9,112
    [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!


  • raja123raja123 Member Posts: 50
    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.