Declaring Variables that can be accessed from all methods of a table

I have four display methods on a table. Each of the methods uses a container that is populated by a class run on the server.

The container is populated with the same data for all four methods, but each method extracts different data from the container using an index.

At the moment the container is declared separately on each of the methods, meaning the server class has to be called four times. Ideally the container would only be declared once and accessed from all four methods. However, unlike a class or form, a table has no class declaration method, so I do not know how to do this.

Is there a way to declare the container so it can be accessed by all the methods in the table.


You can’t declare any member variables in tables, but you can cache the instance of your class. Use SysGlobalCache or (only in AX2012) SysGlobalObjectCache to do that.

Display methods will call a static method in your class (or possibly some other class) to get the instance. The method will return the object form global cache, or will create a new one and put it into cache if none has been cached yet.

If you use SysGlobalCache, be aware that separate cache instances exist on client and AOS - if you cache a value on AOS, you can’t read it on client, for example. For the best performance, the optimal approach may require calculating values on AOS and caching the object on client, so the object would have to be serializable (pack()/unpack()).

This may be helpful.

Thanks, this was what I needed.