BC Friday Tips #20 Sort your triggers in sequence

Sort Triggers

Happy #BCFridayTips for #msdyn365bc developers.

Sort your triggers in sequence.

When writing AL code, arrange triggers in their execution order.

Why?

✅𝗥𝗲𝗮𝗱𝗮𝗯𝗶𝗹𝗶𝘁𝘆. Makes it easier to follow the logic flow.

Example:

dataitem(SalesShipmentLine; "Sales Shipment Line")
{

   trigger OnPreDataItem()
   begin
       //do something
   end;
 
   trigger OnAfterGetRecord()
   begin
       //do something
   end;
 
   trigger OnPostDataItem()
   begin
       //do something
   end;

}


This won’t change performance, but it will make your code clearer for others.

thatnavguy

Experienced NZ-based NAV Developer and Consultant with 15+ years of experience leading multiple IT projects, performing business analyst, developing, implementing, and upgrading Dynamics NAV and Business Central. Passionate to deliver solution that focuses on user-friendly interface while keeping high standard of compliance with the needs.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *