How to Call OnAfterValidateEvent of Table Field via Eventsubscriber

OnAfterValidateEvent of Table Field in Business Central:

What is an Event?

To handle events, you design event subscribers. Event subscribers determine what actions to take in response to an event that has been raised. An event subscriber is a method that listens for a specific event that is raised by an event publisher.

There can be multiple subscribers to the same event from various locations in the application code. When an event is raised, the subscriber methods are run one at a time in no particular order. You can’t specify the order in which the subscriber methods are called.

OnAfterValidateEvent of Field:

It’s executed after a field is validated when its value has been changed.


[EventSubscriber(ObjectType::Table, Database::<Table Name>, ‘OnAfterValidateEvent’,
‘<Field Name>’, <SkipOnMissingLicense>, <SkipOnMissingPermission>)]
local procedure MyProcedure(Rec: Record, xRec: ,CurrFieldno: Integer)


Update “GSTGroupCodeForSale” & “HSNSACCodeForSale” at the time of entering Item No. in the Sales Order. As
shown in the figure.

Example on Call OnAfterValidateEvent of Table Field via Eventsubscriber

Source Code:

codeunit 50001 “Custom Functions-01”
    trigger OnRun()
    [EventSubscriber(ObjectType::Table, Database::”Sales Line”, ‘OnAfterValidateE
vent’, ‘No.’, False, False)]
    procedure OnAfterValidateSOLine(Rec: Record “Sales Line”; xRec: Record “Sales
 Line”; CurrFieldNo: Integer)
        GetItem: Record Item;
        if Rec.Type = Rec.Type::Item then begin
            if (GetItem.HSNSACCodeForSales <> ”) and (GetItem.GSTGroupCodeForSal
e <> ”) then begin
                rec.Validate(“GST Group Code”, GetItem.GSTGroupCodeForSale);
                rec.Validate(“HSN/SAC Code”, GetItem.HSNSACCodeForSales);

How to Call OnAfterInsertEvent (Table) Trigger Event via EventSubscriber
How to configure or use other extensions in BC D365 via dependencies Settings
How to add field in existing Table using extension In D365 BC
Issue in Installing AL Symbol in VS editor [Solved]
OnAfterValidateEvent (Table) Trigger Event– Microsoft Docs

Leave a Reply