Skip to main content

What is Entire Table Caching?

 Entire table caching means that Dynamics 365 F&O keeps a full copy of the table in memory (cache) instead of loading records one by one from the database. So, when the table is used, the system does not go to the database every time . It simply reads the data from the in-memory cache , which is much faster. When is Entire Table Caching used? It is best for: Small tables Parameter or setup tables Tables where data does not change very often Example: A table that stores configuration settings (like number sequences or default parameters) is perfect for entire table caching. Why use Entire Table Caching? Improves performance Reduces database calls Faster read operations

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.InventLocationId, inventTable, inventDim.InventSiteId); // ๐Ÿ”น Get standard configuration (ConfigId) inventDim.ConfigId = inventTable.StandardConfigId; // ๐Ÿ”น Find or create InventDim record inventDim = InventDim::findOrCreate(inventDim); // ๐Ÿ”น Display results info(strFmt("✅ Item ID: %1", itemId)); info(strFmt("InventDimId: %1", inventDim.InventDimId)); info(strFmt("Site ID: %1", inventDim.InventSiteId)); info(strFmt("Warehouse: %1", inventDim.InventLocationId)); } else { warning(strFmt("Item ID %1 not found in InventTable.", itemId)); } }

๐Ÿ’ก Explanation

  • InventTable → Stores item master data.

  • InventDim → Holds dimension combinations (like Site, Warehouse, Config).

  • InventItemOrderSetupMap() → Retrieves order setup data (e.g., purchase, sales, production).

  • InventDim::findOrCreate() → Ensures that a valid InventDimId exists for the given combination.

Comments

Popular posts from this blog

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

How to Open a Form with Filtered Data Using a Button in X++ – A Step-by-Step Guide

 In Dynamics 365 for Finance and Operations (D365FO), a common requirement is to open a form dynamically from another form and pass filtered data based on a specific condition. This functionality can enhance user experience by allowing them to interact with multiple forms seamlessly, while keeping the data relevant and focused. In this blog, we’ll explore how to implement such a solution using X++, where a user clicks a button on Form 1 (such as a list of sales orders), and based on a selected record, Form 2 (such as invoice details) opens with only the relevant filtered data. Scenario Overview Let’s assume the following scenario: Form 1 : Displays a list of sales orders, and each order has an OrderID , CustomerID , and OrderAmount . Form 2 : Displays details of invoices (from the InvoiceDetails table) that are linked to the selected OrderID from Form 1 . The goal is to click a button on Form 1 , pass the OrderID to Form 2 , and display only the relevant invoice records relate...

Sorting Data in X++ (D365FO) Grids Using Form Data Source Events

  Introduction : In Dynamics 365 Finance and Operations, form grids often display data retrieved from a table or query. However, the default sorting applied may not always align with business requirements. Customizing sorting behavior at runtime ensures that the grid data is presented in a meaningful order for users. This blog post demonstrates how to use the Initialized event of a form data source to apply custom sorting to a grid. We will sort the grid rows based on a specific field ( DisplayOrder ) in ascending order. Understanding the Code : Here’s the complete code snippet: --------------------------------------------------------------------------------------------------------------- [FormDataSourceEventHandler(formDataSourceStr(MyFormDataSource,  MyTable), FormDataSourceEventType::Initialized)] public static void MyFormDataSource_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e) {     // It will clear if any other sorting is applied on the grid ...