GeneralJournalLine.VALIDATE("Posting Date", TODAY); GeneralJournalLine.VALIDATE("Document No.", DocNo); GeneralJournalLine.VALIDATE("Document Type", GeneralJournalLine."Document Type"::Payment); GeneralJournalLine.VALIDATE("Account Type", GeneralJournalLine."Account Type"::Customer); [...] GeneralJournalLine.VALIDATE("Account No.", CustLedgerEntry."Customer No."); GeneralJournalLine.VALIDATE("Applies-to Doc. No.", CustLedgerEntry."Document No."); GeneralJournalLine.VALIDATE("Applies-to Doc. Type", CustLedgerEntry."Document Type"); GeneralJournalLine.VALIDATE(Amount, Amount); GeneralJournalLine.VALIDATE("Bal. Account Type", GeneralJournalLine."Bal. Account Type"::"G/L Account"); GeneralJournalLine.VALIDATE("Bal. Account No.", '1210'); IsInserted := FALSE; IsInserted := GeneralJournalLine.INSERT(TRUE); IF IsInserted THEN CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post", GeneralJournalLine)
Answers
Try to put Aplies-To* field validation at the end you your code and in reversed order:
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
R
you should use the same validation sequence in code as you entered recodr manually. With standard object table 81 should be the best solution Slawek suggested.
Try first inserting empty G/L Line with only Template/Batch/Line fields populated, then fill up remaining fields, keeping population order close to how you would populate journal manually.
Populate Apply-To Type/ID fields last, then MODIFY, then post.
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
I had entered also a Validate for the field "Applies-to Ext. Doc. No.", even though the external doc number isn't linked to the G/L entry.
I do insert the populated line, now. It works fine.
Thanks anyway!
rob