Dear All,
I have an event subscriber in a code unit whereby, I need when balance account number is selected, the check on amount field should be done and if its greater than a certain other amount i.e. Amount B, the amount in the purchase journal need to be cleared until the user enters amount that's less or equal to Amount B.
my code below doesn't fire the message and doesn't clear Amount field in the journal line of purchase journal.
[EventSubscriber(ObjectType::Page, Page::"Purchase Journal", 'OnAfterValidateEvent', 'Bal. Account No.', false, false)]
Local Procedure CheckDocumentAmount(var Rec : Record "Gen. Journal Line")
Begin
If Rec.Amount>(Rec.AmountB-Rec.GLBalance) then
Begin
Message('Amount exceeded by %1',Rec."Amount"-(Rec.AmountB-Rec.GLBalance));
Clear(Rec."Debit Amount");
Clear(Rec."Amount");
Clear(Rec."Credit Amount");
Rec.Modify();
Message('The Transaction Amount should not exceed Amount B!');
End;
End;
The even subscriber below with the same code as above doesn't work too
[EventSubscriber(ObjectType::Table, Database::"Gen. Journal Line", 'OnAfterValidateEvent', 'Bal. Account No.', false, false)]
What could be the issue?.