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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Subscribe to IntegrationEvent from ServContractManagement codeunit

(0) ShareShare
ReportReport
Posted on by
Hi,
Strange issue with subscribing to events. This one works perfectly:
    [EventSubscriber(ObjectType::Table, Database::"Service Header", 'OnAfterInsertEvent', '', false, false)]
    procedure ServiceHeader_OnAfterInsertEvent(var Rec: Record "Service Header"; RunTrigger: Boolean)
    begin
        Dialog.Message('OnAfterInsertEvent');
    end;
However, all these fail. They simple do not get called:
    [EventSubscriber(ObjectType::Codeunit, CodeUnit::ServContractManagement, 'OnBeforeCreateLastServLines', '', true, true)]
    local procedure OnOnBeforeCreateLastServLines(ServiceHeader: Record "Service Header"; ContractType: Integer; ContractNo: Code[20]; var IsHandled: Boolean)
    begin
        Dialog.Message('OnOnBeforeCreateLastServLines');
    end;


    [EventSubscriber(ObjectType::Codeunit, CodeUnit::ServContractManagement, 'OnBeforeCreateInvoice', '', true, true)]
    local procedure OnOnBeforeCreateInvoice(var ServiceContractHeader: Record "Service Contract Header")
    begin
        Dialog.Message('OnBeforeCreateInvoice');
    end;
Any suggestions? Purpose is to inject code when a service invoice is generated (all lines are there). For some items compensating lines based upon criteria in a contract type table are to be added.

Please advice
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

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

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,687 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,041 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 974 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans