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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.