Dynamics NAV / Business Central Developer Digest - Vol 381
ArcherPoint’s Developer Digest focuses on Microsoft Dynamics 365 Business Central development and Dynamics NAV development. In Developer Digest Volume 381, we discuss performance for Microsoft Dynamics 365 Business Central AL and Docker artifacts.
The Dynamics NAV and Business Central community, including the ArcherPoint technical staff, is made up of developers, project managers, and consultants who are constantly communicating, with the common goal of sharing helpful information with one another to help customers be more successful.
As they run into issues and questions, find the answers, and make new discoveries, they post them on blogs, forums, social media…so everyone can benefit. We in Marketing watch these interactions and never cease to be amazed by the creativity, dedication, and brainpower we’re so fortunate to have in this community—so we thought, wouldn’t it be great to share this great information with everyone who might not have the time to check out the multitude of resources out there?
So, the ArcherPoint Microsoft Dynamics NAV/BC Developer Digest was born. Each week, we present a collection of thoughts and findings from NAV/BC experts and devotees around the world. We hope these insights will benefit you, too.
Performance for Microsoft Dynamics 365 Business Central AL
Kennie Nybo Pontoppidan has a Twitter thread going about AL performance. Many performance patterns already exist as part of the Performance Tuning Guides by Microsoft; Kennie adds his commentary with these suggestions:
- When concatenating strings, be sure to use the TextBuilder data type and not repeated use of the += operator on a Text variable.
- Do not use BigText in #msdyn365bc AL, if possible. It is an old datatype that does not perform as well as TextBuilder.
- If you need a key-value data structure that is optimized for fast lookups, use a Dictionary data type.
- Use a List data type if you need an unbound “array” (where you would previously create a temporary table object).
- Use the Media or Mediaset data types instead of the Blob data type. The Media and MediaSet data types have a couple advantages over the Blob data type when working with images.
- It’s often desirable to offload AL execution from the UI thread to a background session. Here are some examples of this pattern:
- Don’t let the user wait for batches
- Split large tasks into smaller tasks and run them in parallel
- Pattern – Use set-based methods instead of looping the AL methods such as FindSet, CalcFields, CalcSums, and SetAutoCalcFields are set-based operations that are much faster than looping over a result set and do the calculation for each row.
- Minimize work done in OnAfterGetRecord trigger code. Common performance coding patterns are:
- No CalcFields calls. Defer them until the end.
- Avoid repeated calculations. Move them outside the loop, if possible.
- Do not change filters
- Consider using a query object if you want to use a set-based coding paradigm.
- Pattern – Use partial records when looping over data, in reports, or when table extension fields aren’t needed. This will improve performance because:
- Limits the fields needed to be loaded from the database
- Limits the number of table extension joins
- If you need a fast, non-blocking number sequence that can be used from AL, refer to the number sequence object type. Use a number sequence object if you:
- Don’t want to use a number series
- Can accept holes in the number range
Follow @KennieNP on Twitter for more information.
Developer Tip of the Day: Docker Artifacts
Kyle shares: “You can download a Docker artifact directly and open or extract the contents using 7Zip. It contains source code, apps, configuration packages, and a Cronus database.
Interested in Dynamics NAV and/or Business Central development? Be sure to see our collection of NAV/BC Development Blogs.
Read “How To” blogs from ArcherPoint for practical advice on using Microsoft Dynamics NAV and Dynamics 365 Business Central.