Skip to main content

Posts

πŸ’‘ X++ Tip: Keep the Same Record Selected After Refresh in a Form or Data Source

 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...
Recent posts

Find InventDimId, SiteId, and Warehouse by ItemId in x++

  πŸ”ΉFind InventDimId, SiteId, and Warehouse by ItemId static void FindInventDimByItemId(Args _args) { InventTable inventTable; InventDim inventDim; ItemId itemId = "A0001"; // πŸ”Έ Replace with your item ID InventOrderSetupType setupType = InventOrderSetupType::Sales; // πŸ”Έ Example setup type // Select item from InventTable select firstOnly inventTable where inventTable.ItemId == itemId; if (inventTable) { // Initialize the InventDim record inventDim.clear(); // πŸ”Ή Get Site (InventSiteId) based on item setup inventDim.InventSiteId = inventTable.inventItemOrderSetupMap(setupType) .inventSiteId(inventDim.InventSiteId, inventTable); // πŸ”Ή Get Warehouse (InventLocationId) inventDim.InventLocationId = inventTable.inventItemOrderSetupMap( setupType, InventDim::findOrCreate(inventDim).InventDimId) .inventLocationId(inventDim...

πŸ”§ How to Apply the Latest Service Update to a D365FO Development VM

Keeping your Dynamics 365 Finance and Operations (D365FO) development environment up to date ensures that your system remains compatible with the latest features, fixes, and security improvements. In this guide, we’ll walk through how to apply a Service Update (CU) to a local development virtual machine (VM) step by step. πŸ“₯ Step 1 – Download the Service Update Package Log in to LCS (Lifecycle Services) . Go to Shared Asset Library → Software Deployable Package . Find and select the Service Update you want to apply. Click Download — the file is usually 5–6 GB , so this might take some time. Once downloaded: Right-click the ZIP file → Properties → Unblock , then click OK . Extract it to a non-user folder (e.g., C:\Altitudo\10_0_23 ). ⚠️ Avoid extracting to your Desktop or Downloads folder. 🧩 Step 2 – Collect Topology Configuration Data Inside the extracted folder, locate DefaultTopologyData.xml . This file defines the VM name and installed components for ...

πŸ”„ Manual Database Synchronization in Dynamics 365 Finance & Operations (On-Premises)

 When working with Dynamics 365 Finance and Operations (on-premises) , there are times when you need to manually synchronize the application database (AXDB) with your metadata. This is especially common after deploying new models, applying hotfixes, or troubleshooting schema mismatches. In this guide, we’ll walk through the manual sync process , how to test SQL connectivity , and a quick troubleshooting checklist to ensure smooth execution. πŸš€ Running the Manual Sync Command The sync is triggered using the Microsoft.Dynamics.AX.Deployment.Setup.exe tool. Below is an example command for a full tables and views sync : C:\ProgramData\SF\SBAOS02\Fabric\work\Applications\AXSFType_App83\AXSF.Code.1.0.20251009185555\bin\Microsoft.Dynamics.AX.Deployment.Setup.exe ^ --setupmode sync ^ --syncmode FullTablesAndViews ^ --metadatadir C:\ProgramData\SF\SBAOS02\Fabric\work\Applications\AXSFType_App83\AXSF.Code.1.0.20251009185555\Packages ^ --bindir C:\ProgramData\SF\SBAOS02\Fabric\work\Applicat...

πŸ”„ Convert Available Inventory to Kilograms (KG) in X++ – D365 F&O

When working with raw materials in Dynamics 365 Finance & Operations (D365 F&O), it’s common to encounter situations where the inventory is stored in one unit (like Liters or Packs), but needs to be viewed or calculated in Kilograms (KG) for costing, reporting, or analysis. In this blog, we’ll walk through a practical X++ code snippet that demonstrates how to convert available inventory (AvailPhysical) into KG using D365’s standard Unit of Measure (UOM) conversion. πŸ“Œ Business Scenario Suppose you have a chemical item stored in Liters , but the production or costing team needs to see its available inventory in KG . You’ll need to: Fetch the item’s AvailPhysical from the InventSum table. Get the current unit of measure (UOM) for the item. Convert that quantity into KG , based on predefined unit conversion. πŸ’» X++ Code – Inventory Conversion to KG Here’s the code block that does exactly that: //******************** Avail Physical as per KG Unit conversion *...

πŸš€ How to Dynamically Copy Matching Fields Between Tables in X++ using DictTable

 In Microsoft Dynamics AX (X++), there are many scenarios where you need to duplicate data from one table to another—especially during custom import, duplication, or versioning processes. Traditionally, this is done by manually assigning each field: targetTable.Field1 = sourceTable.Field1; targetTable.Field2 = sourceTable.Field2; ... But what if the tables have many fields ? Or maybe you’re dealing with multiple similar table pairs? That’s where the powerful DictTable class comes in. Let’s walk through how to use it to copy matching fields dynamically between two tables. πŸ’‘ Use Case: Copy Customer Templates Let’s assume you have these tables: CustTemplateHeader – stores predefined customer templates. CustTemplateHeaderHistory – a historical copy of templates for versioning. You want to copy records from CustTemplateHeader to CustTemplateHeaderHistory , but only for fields that exist in both tables. ✅ The Solution Using DictTable SalesHeaderTemplate   ...

How to Refresh a Form or Data Source in D365FO Using X++

  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...");     ...