When you refresh a form data source in Dynamics AX or Dynamics 365 for Finance and Operations, the current selection is often lost — the cursor jumps back to the first record. This can be frustrating, especially if you want the user to remain on the same record after an update or refresh. Here’s a simple and reliable way to restore the cursor to the same record after the data source is refreshed. 🧩 Scenario Suppose we have a form displaying records from MyTable . When we refresh the data source — for example, after updating a field or calling executeQuery() — we want the form to return to the same record the user was viewing before the refresh. ✅ Solution: Use ds.cursor() We can achieve this using a record buffer and the cursor() method of the data source. public void refreshDataSource() { MyTable myTableRec; // buffer to store current record // Store the current record myTableRec = MyTable_ds.cursor(); // Refresh the data source MyTable_ds.r...
Introduction In Microsoft Dynamics 365 Finance & Operations (D365FO), refreshing the form after an action (like inserting, updating, or deleting a record) is essential for keeping the UI updated with the latest data. In this blog, we’ll explore two ways to refresh the form in X++: ✅ Refreshing the entire form using taskRefresh ✅ Refreshing a specific data source using research Let's dive into the best practices for implementing these refresh methods! 🔄 Refreshing the Entire Form If you need to refresh the whole form , use the taskRefresh method. This method is useful when multiple data sources are involved, and you want to reload everything. 📌 X++ Code for Full Form Refresh public void refreshForm() { // Get the current form instance FormRun formRun = this.formRun(); // Check if formRun is valid before refreshing if (formRun) { info("Refreshing the form..."); ...