FormDataSource.cacheAddMethod Method

Registers the specified display or edit method for caching.

Syntax

public boolean cacheAddMethod(str methodName, [boolean updateOnWrite])

Run On

Client

Parameters

  • methodName
    Type: str
    The name of the method to register for caching.
  • updateOnWrite
    Type: boolean
    A Boolean value that determines whether the cached value is updated automatically when the record is written; optional.

Return Value

Type: boolean
true if the method was registered successfully; otherwise, false.

Remarks

Cached methods perform calculations on fetched data, and then the calculated values are passed to the client together with the data. The calculated values are updated on reread. By default, the values are also update on write and create.

This method should be called after initialization of the data source, but before any data is fetched. Therefore, the call to this method should be put after the call to the super method in the init method.

The updateOnWrite parameter also determines whether the display or edit method value should be calculated and cached when a new record is created. To manually update the cached value for the display or edit method, call the FormDataSource.cacheCalculateMethod method.

Only table methods that have the display or edit keyword can be cached. Methods that are written on the form or the form data source cannot be cached.

Do not register display or edit methods that are not used on the form. Those methods are calculated for each record, even though the values are never shown.

Examples

The following example registers two methods for caching on the VendTransOpen table.

public void init() 
{ 
    super(); 
    this.cacheAddMethod(tablemethodstr(VendTransOpen, 
        nextCashDiscDate)); 
    this.cacheAddMethod(tablemethodstr(VendTransOpen, 
        nextCashDiscAmount)); 
}

See Also

FormDataSource Class

FormDataSource.init Method

FormDataSource.cacheRemoveRecord Method