When unapplying a customer or a vendor ledger entry you sometimes get the error “The latest Transaction No. must be an application in Vendor Ledger Entry No. ######”.  I have found that this can be triggered if “Adjust Exchage Rates” batch has been executed after the prior application posting.

This can be avoided by changing the function FindLastTransactioNo in Codeunit 227.

[code]FindLastTransactionNo(VendLedgEntryNo : Integer) : Integer
"Vendor Ledger Entry No.","Entry Type");
"Vendor Ledger Entry No.",VendLedgEntryNo);
LastTransactionNo := 0;
IF DtldVendLedgEntry.FIND(‘-‘) THEN
//# Changes Start
IF SourceCodeSetup."Exchange Rate Adjmt." = ” THEN
IF DtldVendLedgEntry."Source Code" <>
SourceCodeSetup."Exchange Rate Adjmt."
//# Changes End
IF (DtldVendLedgEntry."Transaction No." > LastTransactionNo) AND
NOT DtldVendLedgEntry.Unapplied
LastTransactionNo := DtldVendLedgEntry."Transaction No.";
UNTIL DtldVendLedgEntry.NEXT = 0;

5 thoughts on “Transaction No. error when UnApplying

  1. Bobby says:

    Hello there,
    Thanks for this solution – I have just tried it and it seems to address the problem with unapplication of vendor ledger entries after adjustment of exchange rates. I have checked the underlying Detailed Customer Ledger entries, and the exchange rate unrealise gains applied to the transaction have been reversed correctly. Brilliant solution!! Bobby

  2. Harry says:

    Thanks. It is works and help…. you really a brilliant

  3. Pramod says:

    Thank you 🙂 🙂

  4. Michael Coscas says:

    Hi Gunnar,
    I try to build a code that unapplies customer entries. For that i call the function “PostUnApplyCustomer” from the codeunit 226 (“CustEntry-Apply Posted Entries”). I get the error “Before you can unapply this entry, you must first unapply all application entries that were posted after this entry.”.
    I understand the error but i do not understand why NAV does not permit us to unapply any transaction and what are the consequences if modify the code to permit this. (for example add a condition as you did in your example above).

    Thanks in advance for your help.


    1. Hi Michael.
      Make sure you start from the last “Detailed Cust. Ledg. Entry” of “Entry Type”::Application for that customer.

Leave a Reply

%d bloggers like this: