Hi All
I'm trying to make dimension code 2 field mandatory on payment journal. However though I have specified the journal template = payment, the validation is triggered on cash receipt and general journals. How do I isolate this check to the particular journal type (payment) ?
Here's my code so far:
[EventSubscriber(ObjectType::Codeunit, codeunit::"Gen. Jnl.-Post Batch", 'OnBeforePostGenJnlLine', '', true, true)]
local procedure CheckDim2Paymt(var GenJournalLine: Record "Gen. Journal Line")
var
begin
GenJournalLine.Reset();
GenJournalLine.SetRange("Journal Template Name", 'PAYMENT');
GenJournalLine.SetFilter(Amount, '<>%1', 0);
GenJournalLine.SetRange("Shortcut Dimension 2 Code", '');
if GenJournalLine.FindFirst() then
error('check dim2');