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 ...

Get Microsoft Dynamics AX 2012 Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.