Caching a display method
In Dynamics AX, display methods are widely used to show additional information on forms or reports that come from different data sources, including special calculations, formatting, and more.
Display methods are shown as physical fields and are executed each time the form is redrawn. This means that the more complex the method is, the longer it takes to display it on the screen. Normally, it is recommended to keep the code in display methods to a minimum.
The performance of display methods can be improved by caching them. This is when display method's return value is retrieved from a database or calculated only once, and subsequent calls are made to the cache.
In this recipe, we will create a new cached display method. We will also discuss a few scenarios to learn how to properly use caching.
How to do it...
Carry out the following steps in order to complete this recipe:
1. In the AOT, locate the CustGroup table and create a new display method with the following code...