Dynamics Business Central / NAV Developer Digest - Vol. 560

ArcherPoint by Cherry Bekaert’s Developer Digest focuses on Microsoft Dynamics 365 Business Central and Dynamics NAV development. This week’s volume includes mutants in AL code, idempotency for BC job queue transactions with the external system, managing BC database indexes, and accessing error information in BC.
The Dynamics 365 Business Central community, consisting of developers, project managers, and consultants, collaborates across various platforms to share valuable insights. At ArcherPoint, we greatly value their dedication and expertise. To ensure widespread access to this technical knowledge, we created Developer Digest.
Where are there mutants in your AL code?
Code testing can be tricky.
If you run a test and it comes back green, does that mean everything is ok? Not necessarily.
Torben Leth recommends testing your tests: In a sandbox, delete a critical line of code from a codeunit and run your tests. The test should catch the breaking code. If it doesn’t, you haven’t really tested your code.
Introducing deliberate changes (mutants) to the code and then running your test cases against it is called “mutation testing”. Mutation testing evaluates whether the test suite effectively finds the faults in your code. Undetected mutants reveal inadequate test coverage.
Leth discusses the problem and proposes an open-source solution he calls “LethAL”, developed specifically for AL developers.
Read his blog, Your Tests All Pass. I Have Bad News, to learn more and to download LethAL.
Idempotency for BC job queue transactions with external system
An error when sending a job queue transaction from Business Central to an external system can create significant production problems if you’re not looking for it. Examples include posting to an external API or calling a payment gateway.
Depending on how you code the transaction, the external system might update properly, but the error causes the Business Central database to roll back as if nothing ever happened. The job queue will see the transaction as still pending and retry the transaction. This can lead to a duplicate operation on the external system, such as a duplicate payment or a second shipment.
By introducing idempotency, you ensure that running the same operation multiple times will not create a duplicate action on the external system if it has already taken place.
Stefano Demiliani discusses this potential problem and offers a solution in his blog, Why your Business Central job queue needs idempotent external effects when integrating external systems.
As he puts it, “Don’t assume a rolled-back AL transaction means nothing happened.”
Managing BC database indexes
New in BC 2026 Wave I is the ability for administrators to manage database indexes from the BC client, providing greater control over storage requirements and database performance.
Administrators can now view all indexes in a table, monitor index size and usage, and manage indexes across companies.
However, every INSERT, MODIFY, or DELETE operation affects your indexes, leading to increased storage requirements, slower write operations, and additional maintenance overhead.
Saurav Dhyani expands on these capabilities, along with important considerations, best practices, and an FAQ, in his blog Manage Database Index Usage in Business Central.
Accessing error information in BC
Business Central lets developers view information about the last known error, which can originate from situations such as field validation and posting routine errors.
Viewing the last error is provided by the following methods:
- System.GetLastErrorCode(): Returns the type of the last error that occurred.
- System.GetLastErrorText(): Returns the details of the last error that occurred in the debugger.
- System.GetLastErrorCallStack(): Returns the call stack from where the last error occurred.
Yun Zhu explains these methods and provides examples of their usage in his blog, Dynamics 365 Business Central: GetLastErrorCode, GetLastErrorText and GetLastErrorCallStack Methods.
Are you interested in Dynamics NAV and Business Central development? Check out our collection of NAV/BC Development Blogs.
Read “How To” blogs from ArcherPoint by Cherry Bekaert for practical advice on using Microsoft Dynamics NAV and Dynamics 365 Business Central.
Trending Posts
- Login Error: Communication protocol mismatch between client and server
- How to Make Measures Total Correctly in Power BI Tables
- The Microsoft Technology Stack – What Is It & Why Should You Care?
- MRP vs. MPS: Choosing the Right Planning Approach for Your Manufacturing Business
- Guide to How Manufacturers Can Implement Quality Control Systems Using Business Central
Stay Informed
Subscribe to Communications
"*required" indicates required fields