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...
Process of making a POST request in X++ using the WinHttp class step by step. 1. Setup Before making an HTTP request, ensure you have the necessary URL, headers, and payload data you want to send. 2. Create the HttpWebRequest Object You will first need to create an instance of HttpWebRequest by specifying the URL you want to send the POST request to. 3. Configure the Request Set the HTTP method to POST and configure any necessary headers and content type. Prepare the request body as a byte array. 4. Send the Request and Handle the Response Write the request body to the request stream, send the request, and read the response. Example Code Here’s a detailed step-by-step example in X++: static void PostRequestExample(Args _args) { System.Net.HttpWebRequest request; System.Net.HttpWebResponse response; System.IO.Stream requestStream, responseStream; System.IO.StreamReader reader; System.Text.Encoding utf8; ...