Hi
We recently had support case where a client suddenly had a bunch of Genereal Journal Lines lose their Account No.'s. The culprit is the following code on Table 81 that is called in the OnDelete Trigger (among others).
ClearAppliedGenJnlLine()
IF "Applies-to Doc. No." = '' THEN
EXIT;
GenJournalLine.SETRANGE("Journal Template Name","Journal Template Name");
GenJournalLine.SETRANGE("Journal Batch Name","Journal Batch Name");
GenJournalLine.SETFILTER("Line No.",'<>%1',"Line No.");
GenJournalLine.SETRANGE("Document Type","Applies-to Doc. Type");
GenJournalLine.SETRANGE("Document No.","Applies-to Doc. No.");
GenJournalLine.MODIFYALL("Applied Automatically",FALSE);
GenJournalLine.MODIFYALL("Account Type",GenJournalLine."Account Type"::"G/L Account");
GenJournalLine.MODIFYALL("Account No.",'');
Scenario is as follows:
A user enters a number of lines in the Cash Receipt journal. All lines have the same Document No. They are of Document type Payment. As it happens the user also enters a Refund line that is applied to a previously posted payment with the same documentno.. So Applies-to Doc. Type is "Payment". "Applies-to Doc. No." is the same Document No. as other payments in the same journal.
Yo and behold. User comes back 10 minutes later. Figures.. nah.. I don't want that refund line in the journal. Then proceeds to delete the Refund line.
The above code now alters all other lines in the journal. Setting Accont Type to G/L Account (Was customer) and Account No. to '' ...
Why is he using the same Document No. I hear you all say. Well. he just happens to want it that way and nothing is preventing him from doing it. But after deleting that one Refund an entire days work (potentially) is lost.
Anyone know why Microsoft decided to add that piece of code and how it got through QA?