Difference Between refresh(), reread(), research(), and executeQuery()
1. refresh()
-
It only refreshes the data already loaded on the form.
-
It does not go to the database.
-
It simply updates the form UI with the data that is already in the form cache.
Example:
If you change a field value in code and want the form to immediately show the updated value, use refresh().
2. reread()
-
It reads the current record again from the database.
-
It does not refresh the grid/form automatically.
-
It is used when you want the latest version of only the current record, not the whole list.
Example:
If another process updated the same record in the background and you want to load the latest values from DB, use reread().
3. research()
-
It re-runs the form’s existing query on the datasource.
-
It keeps the existing filters, sorting, and ranges.
-
It refreshes the data on the form based on the same query that is already applied.
Example:
If new records were added that match the same filters, use research() to reload the form data.
4. executeQuery()
-
It re-runs the query after you have modified the query in code.
-
It is similar to
research(), but it also considers any new changes you made to the query, such as:-
Adding new ranges
-
Changing filters
-
Editing joins or relations
-
Example:
If you change the query by adding a range (filter) in X++ and want the form to refresh using this new query, use executeQuery().
Quick Summary Table
| Method | Goes to DB? | Refreshes Form UI? | Keeps Filters? | Use When… |
|---|---|---|---|---|
| refresh() | No | Yes | Yes | Only UI needs to update (no new DB data) |
| reread() | Yes (single record) | No | N/A | You need the latest version of current record |
| research() | Yes | Yes | Yes | Re-run the same query with same filters |
| executeQuery() | Yes | Yes | No (query changed) | You changed the query in code and want updated results |
Comments
Post a Comment