- All these four methods (refresh, reread, research and executeQuery) on datasource always create panic to the developers irrespective their experience they had in AX about where to use what method.
I've done some research on this during few assignments and here are few findings.
- Refresh Data displayed in the form controls will get refreshed using this method irrespective of what is stored in form cache for that datasource record. One more important thing, Calling refresh() method will NOT reread the record from the database and so if changes occurs to the record in any other process, those will not be shown after executing refresh().
Reread This method will query the database and re-read the current record contents into the datasource. This will not display the changes on the form until a redraw of the grid contents happens (e.g you need to navigate away from the column or re-open the form).
Research Existing form query will rerun in database while calling of method research() and therefore updating the list with new/removed records as well as updating all existing rows.
Research(true) -The research method in DAX 2009 accepts an optional boolean argument _retainPosition. If you call research(true), the cursor position in the grid will be preserved after the data has been refreshed. This is an extremely useful addition, which solves most of the problems with cursor positioning (findRecord method is the alternative, but it may cause some performance issue).
ExecuteQuery Calling executeQuery() will also rerun the query and update/add/delete the rows in the grid.