Skip to main content

Posts

Showing posts from February, 2025

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