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 firing multiple times for Customer table

(1) ShareShare
ReportReport
Posted on by

Hi,

I have created an Event subscriber on the "Customer" table in a codeunit. In my subscriber procedure i send a payload to an external server with information from the record that raised the event. My issue is that when i raise the "OnAfterInsertEvent", my server receives 2 payloads for the insert event and almost 6 payloads for a modify event.

Example Event Subscriber: 

* INSERT MODIFY and DELETE events all look the same except for the 'insert' hardcoded, each are 'insert','modify','delete' respectively. also the 'OnAfter<event>Event' is different respectively.

  [EventSubscriber(ObjectType::Table, Database::Customer, 'OnAfterInsertEvent', '', true, true)]
  local procedure CustomersOnAfterInsertEvent(var Rec: Record Customer; RunTrigger: Boolean)
  var
    payload: JsonObject;
    payload_text: Text;
    data: JsonObject;
  begin
    data.Add('id', Rec.SystemId);
    payload := buildPayload.StandardPayload(data);
    buildPayload.StandardRequest( payload);
  end;

Here is an example of the payload i receive 2 of.

{
table: 'Customer',
data: { id: '05F41CA7-4FEB-EC11-82F8-0022482AD7A0' },
trigger: 'insert',
}

Here is an example of the payload i receive 6 or more of.

{
table: 'Customer',
data: { id: '05F41CA7-4FEB-EC11-82F8-0022482AD7A0' },
trigger: 'modify',
}

I would like to think that my logic is correct because these exact event subscribers work 100% perfectly fine for the other tables i have them on 'Sales Orders' being another one. This issue only occurs for the Customers table which is why i believe it may have to do with how msbc handles event subscribers. 

Could this have anything to do with what MSBC does internally that would fire the event subscriber multiple times.

Any information on how event subscribers are handled (especially the customer table) would be useful for my understanding. 

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Hi ,

    Few questions I have, are you are only person in BC creating new customer? Can you please check if there is any other customization which is creating new customer on a particular case? Also please try to run the same case in new demo company

    Thanks.

  • Community Member Profile Picture
    on at

    Thank you for responding, I isolated the the subscriber event to a different test company and the same happened. I am sure that this is the only event subscriber on the customers table. Also, i went back to double check and for some reason 'Sales Header' on insert event also returns 2 payloads indicating the event fired twice. I did notice something interesting though, when i isolated the customer subscriber to a different company as soon as i clicked the +New button in MSBC i got an insert payload. Then when i added the customer number and name i got a modify payload. Any ideas or thoughts on this weird behaviour? If you're interested, to recreate just add a subscriber to the customers table like i show above and send that to an external api that just console logs. Thats literally all i have currently.

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 2,785

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 948 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans