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.