web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Event Subscriber not working

(0) ShareShare
ReportReport
Posted on by

Dear All,

Hi, I am subscribing an event to a custom table. But I am not getting my required result. I need a message when 

OnAfterValidateEvent runs. It's not firing even a simple message. Below is my sample code.

EventSubscriberInstance = StaticAutomatic;

[EventSubscriber(ObjectType::Table, Database::"Payment Document Line", 'OnAfterValidateEvent', 'Applies-to Doc. Type', true, true)]
local procedure OnAfterValidateEvent(VAR Rec: Record "Payment Document Line")


var

PurInvLine: Record "Purch. Inv. Line";

Begin



CASE Rec."Account Type" OF
Rec."Account Type"::Vendor:
BEGIN


If Rec."Document Type" = Rec."Document Type"::Invoice then Begin

Message('yes its an invoice');

End
End;


Rec."Account Type"::"Bank Account":

Exit;
Rec."Account Type"::"G/L Account":

Exit;
Rec."Account Type"::Customer:

Exit;
Rec."Account Type"::Employee:

Exit;
Rec."Account Type"::"Fixed Asset":

Exit;
Rec."Account Type"::"IC Partner":

Exit;

End
End;
I have the same question (0)
  • Suggested answer
    Andy Sather Profile Picture
    Microsoft Employee on at

    Hello  - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

  • Suggested answer
    JAngle Profile Picture
    150 on at

    Have you determined that the values are passed to that table with validation? Payment Document Line is not a table I’m familiar with in the GB localisation at least. I’d assume it is created when an open purchase invoice or purchase order is posted for an invoice? If so the transferfields function might be used. This is what happens for an invoice at least. Because the data is already valid from entry at the earlier stage there is no need to revalidate it - it’s just more lines of code to run when it’ll be an exact copy. You might get more joy with a different event

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,958 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,101 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans