Refresh vs. Reread vs. Research vs. ExecuteQuery in D365 F&O
Understanding the difference between refresh(), reread(), research(), and executeQuery() in D365 F&O is essential when working with forms and data sources. This blog explains what each method does, when to use it, and how to refresh form data correctly without unnecessary database interactions.
Refresh vs. Reread vs. Research vs. ExecuteQuery in D365 F&O
When working with forms in Dynamics 365 Finance & Operations, we often need to interact with existing records, update data, or refresh the information displayed to users. Depending on the scenario, we may need to refresh the current record, retrieve updated values from the database, or rerun the entire form query.
D365 F&O provides several methods for handling these scenarios, including refresh(), reread(), research(), and executeQuery(). Although these methods may appear similar, each serves a different purpose. Understanding when to use each one can help avoid unnecessary database calls and unexpected form behavior.
1. refresh()
The refresh() method refreshes the form controls using the data currently available in the data source buffer. It does not, by itself, fetch updated records from the database.
For example, if the data source already contains a record and its values have been modified in the buffer, calling refresh() updates the displayed controls based on that buffer.
Use refresh() when: You want to refresh the UI based on the current data source buffer, without retrieving the record again from the database.
formDataSource.refresh();2. reread()
The reread() method retrieves the current record again from the database and updates the data source buffer with the latest values.
However, the form controls may not immediately reflect those changes until you call refresh() afterward.
This is particularly useful when the current record has been updated by another process, another user, or code executed outside the current form buffer.
Use reread() when: You want to fetch the latest database values for the current record.
formDataSource.reread();
formDataSource.refresh();When you need the latest database values to be reflected in the UI, calling reread() followed by refresh() is a common approach.
3. research()
The research() method reruns the data source query to retrieve records again. It is useful when the underlying data may have changed and you want the form to reflect those changes, including newly added or removed records that match the query.
Unlike reread(), which refreshes the current record, research() refreshes the result set of the data source.
Use research() when: You want to rerun the existing query and refresh the records displayed in the form.
formDataSource.research();4. executeQuery()
The executeQuery() method executes the data source query. It is particularly useful when you have modified the query, such as adding or changing ranges, and want the form to retrieve records based on those changes.
For example, if you dynamically modify a query range in your code, calling executeQuery() allows the data source to execute the updated query and display the resulting records.
Use executeQuery() when: You have modified the query or its ranges and need to execute the updated query.
formDataSource.executeQuery();Quick comparison
Method | Purpose | Database interaction |
| Refreshes UI from the current data source buffer | No new fetch by itself |
| Fetches the latest values for the current record | Yes |
| Reruns the existing query and refreshes the result set | Yes |
| Executes the data source query, including applicable query modifications | Yes |
Conclusion
Choosing the right data source method depends on what you are trying to refresh. If you only need to update the UI, refresh() may be sufficient. If you need the latest values for the current record, use reread() followed by refresh(). If you need to refresh the result set, use research(), and if you have modified the query and want to execute it, use executeQuery().
Understanding these differences makes form development in D365 F&O more predictable, efficient, and easier to maintain.