Posts

Events and Subscribers in Business Central AL: How to Stop Modifying Base Code (C/AL Developer Guide)

In C/AL, customizing Dynamics NAV usually meant one thing: open the standard object and change it . Add a few lines to codeunit 80, tweak a trigger on the Customer table, mark the change with your initials, done. In Business Central AL, you cannot do that anymore . Base application objects are locked. Your code lives in an extension, and the only way to "hook into" standard logic is through events . If you are coming from C/AL, this is the single biggest mindset change. This post explains how events work, which types you will use every day, and the mistakes that catch almost every developer in their first month. Why Events Replaced Code Modifications Every code modification in NAV created an upgrade problem. When Microsoft shipped a new version, someone had to merge your changes line by line into the new base objects. On a heavily customized database, that could take weeks. Events fix this by separating two roles: Publisher : the standard code announces "...

Retry Logic for HttpClient in Business Central AL: Handling 429 and 503 Errors

When you call an external API from Business Central using HttpClient , the happy path is easy. The hard part starts when the API returns 429 Too Many Requests or 503 Service Unavailable . A single failed call can break a posting routine, leave a sales order half-synced, or throw a raw error at the user. This post shows a clean, production-ready retry pattern in AL with exponential backoff. Why You Need Retry Logic Most modern APIs (payment gateways, WhatsApp Cloud API, shipping providers, Azure services) enforce rate limits. When you exceed them, the server responds with HTTP 429 and often a Retry-After header. Transient failures like 503 and 504 are also common under load. Without retry logic, your integration is only as reliable as the busiest second on the remote server. The Core Pattern The idea is simple: wrap the send call in a loop, catch retryable status codes, wait a growing interval between attempts, and give up after a maximum number of tries. codeunit 50120 ...