I have an event called "EntityCreated", which is triggered whenever a new record is created. When this happens, I need to send an email notification to the user containing all the relevant information about the entity.
I'm considering two approaches:
1. Pass only the EntityId to the event
2. Pass the full entity structure to the event
Which solution is better?
Hi Lukasz,
According to OutSystems best practices, always fetch only the fields you need from the database and to not pass records as Inputs, to avoid passing redundant information and large records.
Define specific structures with just the required attributes, rather than returning entire entities as I/O parameters, so the platform can optimize queries and improve performance.
Hi @Łukasz Kaproń ,
Instead of using the parameter of the entity structure, use a new structure with attributes relevant to the email that you have to notify. This will be one of the best approachesThanks
Hi @Łukasz Kaproń,
Pass only the EntityId is generally the better approach. If the structure of the entity changes, the event handler doesn't necessarily need to change (as it fetches the latest data itself).