Friday, March 10, 2017

Refresh caller datasource in the list page AX 2012

Today I am going to share with you sample code for updating the caller datasource on list page action menu item. We normally refresh the caller data source on a normal form like this way.


FormRun callerForm;

callerForm = element.args().caller();

callerForm.dataSource().refresh();
callerForm.dataSource().reread();
callerForm.dataSource().research();

In case of a list page how would you get the grid to refresh since the list page does not allow any override methods, because it uses Interaction Class. However, if I am going to use an action menu item. Code sample provided bellow is useful for this purpose.



void main(Args _args)
{

FormDataSource   callerDataSource;

callerDataSource = _args.record().dataSource();
callerDataSource.refresh();


callerDataSource.reread();
callerDataSource.research(true);
}



Thanks to read the post and hope that will help you in refresh the caller data source both for list page and normal form.