Announcements
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.
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.
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.
André Arnaud de Cal...
294,101
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator