Sunday, 21 July 2013

Refresh caller form [AX 2012]

There are a few ways to refresh a caller form. You may notice in AX2012 sometimes calling research(true) causes the record to jump to the starting position.

The right way is to reread the references data sources before calling the research(true). Below is some sample code I use.

/// <summary>
/// Refresh the caller form by calling the research(true) which does not work.
/// research(True) alone will jump the cursor to the begining (either first or last) record.
/// </summary>
/// <remarks>
/// Taken from form InventTableInventoryDimensionGroups.closeOk()
/// </remarks>
public void refreshCaller()
Common common;
FormDataSource callingFormDataSource;

common = element.args().record();
if (common)
callingFormDataSource = common.dataSource();
if (callingFormDataSource)
// Referenced datasources must be reread before calling research as data has been modified behind the scenes
// without calling research will fail to position selection correctly

No comments: