Skip to main content

🔎 How to Get Line-wise Other Charges Tax Amount in D365FO (IGST / CGST / SGST)

 In many D365FO implementations (especially India GST projects), we often need: Line-wise Other Charges Tax Amount Split into IGST, CGST, and SGST For Posted Customer Invoice Lines (CustInvoiceTrans) By default, D365FO stores: Invoice Lines → CustInvoiceTrans Charges → MarkupTrans Tax → TaxTrans To get accurate charges tax per invoice line, we must follow proper table relation hierarchy. 📌 Table Relationship Structure CustInvoiceTrans → MarkupTrans → TaxTrans Relationship Logic: MarkupTrans.TransTableId == tableNum(CustInvoiceTrans) MarkupTrans.TransRecId == CustInvoiceTrans.RecId TaxTrans.SourceTableId == tableNum(MarkupTrans) TaxTrans.SourceRecId == MarkupTrans.RecId This ensures we fetch only Charges Tax , not Item Tax. 🧠 Business Requirement For each invoice line, we need: IGST Amount CGST Amount SGST Amount Converted to positive value (if negative) 💻 X++ Code – Line Wise Charges Tax Calculation Cus...

Difference Between refresh(), reread(), research(), and executeQuery()

 

Difference Between refresh(), reread(), research(), and executeQuery()

1. refresh()

  • It only refreshes the data already loaded on the form.

  • It does not go to the database.

  • It simply updates the form UI with the data that is already in the form cache.

Example:
If you change a field value in code and want the form to immediately show the updated value, use refresh().


2. reread()

  • It reads the current record again from the database.

  • It does not refresh the grid/form automatically.

  • It is used when you want the latest version of only the current record, not the whole list.

Example:
If another process updated the same record in the background and you want to load the latest values from DB, use reread().


3. research()

  • It re-runs the form’s existing query on the datasource.

  • It keeps the existing filters, sorting, and ranges.

  • It refreshes the data on the form based on the same query that is already applied.

Example:
If new records were added that match the same filters, use research() to reload the form data.


4. executeQuery()

  • It re-runs the query after you have modified the query in code.

  • It is similar to research(), but it also considers any new changes you made to the query, such as:

    • Adding new ranges

    • Changing filters

    • Editing joins or relations

Example:
If you change the query by adding a range (filter) in X++ and want the form to refresh using this new query, use executeQuery().


Quick Summary Table

MethodGoes to DB?Refreshes Form UI?Keeps Filters?Use When…
refresh()NoYesYesOnly UI needs to update (no new DB data)
reread()Yes (single record)NoN/AYou need the latest version of current record
research()YesYesYesRe-run the same query with same filters
executeQuery()YesYesNo (query changed)You changed the query in code and want updated results

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