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

Notifications

Announcements

No record found.

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
    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
    133 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,098

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,556 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,108 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans