Thursday 13 July 2017

Improve performance to display methods on forms by using “Caching display methods”

The performance of display methods can be improved by caching them if they are calculated on Application Object Server (AOS).  Caching display methods can also improve performance when records are transferred from the server to the client.

Syntax

Formdatasource.cacheAddMethod(tableMethodStr(<Table_Name>, <DisplayMethod>));

The value of all cached methods is set when data is fetched from the back-end database. In addition, the value is refreshed when the reread() method is called on the form data source. 

Example:

AOT -> Forms -> CustTable -> Datasources -> CustTable  -> init()

you can see  cacheAddMethod() 

Caching Display Method

AX2009 and AX2012 both supports the above method, but in AX2012 we have one more way to caching display method by using SysClientCacheDataMethodAttribute attribute in the display method declaration, Its perform automatically be cached on  any form where it’s used

Syntax
[SysClientCacheDataMethodAttribute([_updateOnWrite])]
display type methodName (parameters) 
{
}
Example
[SysClientCacheDataMethodAttribute(true)]
display CustAccount displayCustAccount()
{
    return (select firstOnly accountNum from custTable
                where custTable.accountnum == this.custAccount).accountNum ;
}



No comments:

Post a Comment