Loading...

How to Calculate purchase order total value using X++ in Dynamics 365 FO?

How to Calculate purchase order total value using X++ in Dynamics 365 FO?
In the previous article  “Field Fixed Relation in D365 with Example “, you learned what is a Field Fixed relation and how to make a Field Fixed table relation in Dynamics 365 fo. Additionally, you learned an example associated with field fixed relations. In this article, you can learn, what is a POwhat is purchase order total value and How to Calculate the purchase order total value in D365 using X++ code.

What is a Purchase Order?

A Purchase Order is a document that represents a request to a vendor to supply goods or services at a specific price and delivery date. The purchase order includes details such as the quantity, unit price, and delivery date of the items or services requested, as well as the vendor's information and the buyer's information.

A purchase order is typically created in the procurement and sourcing module in Dynamics 365 Finance and Operations, and it can be generated automatically from a requisition or manually entered by a user. Once the purchase order is approved and sent to the vendor, it serves as a legally binding agreement between the buyer and the seller.

The purchase order also serves as a basis for tracking the status of the order and receiving the items or services in the receiving and warehousing module. It can also be used for invoice matching and for tracking vendor performance metrics.

Why this article?

It is often difficult to calculate the totals of PO using X++ in D365FO. The form of totals in the Purchase order shows different totals of PO, but it is difficult for developers to get them using X++ code. For this purpose, I am writing this article to give you the code to calculate the totals of PO using X++.

What is Purchase Order Total?

In Dynamics 365 Finance and Operations, the Purchase Order Total refers to the total cost of the items or services requested in a purchase order. This includes the price of the items or services, any applicable taxes or fees, and any additional charges such as shipping or handling fees.

The Purchase Order Total is calculated automatically in Dynamics 365 Finance and Operations based on the details entered in the purchase order. It can be viewed on the purchase order form and can also be used in various financial and accounting processes, such as budgeting, cost accounting, and financial reporting.

Having an accurate Purchase Order Total is important for effective budget management and financial control, as it enables buyers to track and manage their purchasing activities more effectively and provides greater transparency into the costs associated with their procurement processes.

In Dynamics 365 FO, you can review the totals of PO using the following steps:

1. Under Module >  Click on Procurement and Sourcing Module.

How to Calculate purchase order total value in Dynamics 365 FO?

     2. Under purchase orders > Click on All purchase order menu.

How to Calculate purchase order total value in Dynamics 365 FO?

3. You can see all the purchase orders created previously, select one purchase order.

How to Calculate purchase order total value in Dynamics 365 FO?

You can see the Total under the Purchase Order tab on the action bar.

How to Calculate purchase order total value in Dynamics 365 FO?

4. Click the menu Total, and a dialog box shows totals for the whole order.

How to Calculate purchase order total value in Dynamics 365 FO?

Calculate the purchase order total value using X++

For this,

1. Create a runnable class (job) named as CalculatePurchaseOrderTotals.

2. Copy the below code and paste it into the newly created class.

internal final class CalculatePurchaseOrderTotals
{

   public static void main(Args _args)
   {
       //Calculate totals per Purchase order
       PurchTotals purchTotals;
       PurchTable  purchTable  = PurchTable::find('00000041'); //Change the Purchase Order Id as per your system's data
       AmountCur   totalAmount;
       purchTotals = PurchTotals::newPurchTable(purchTable);
       purchTotals.calc();
       totalAmount = purchTotals.purchTotalAmount();
       info(strFmt("Purchase order: %1 - Total value: %2", purchTable.PurchId, totalAmount));
   }
 
}
How to Calculate purchase order total value using X++ in Dynamics 365 FO?

3. Change the Purchase order id according to your system’s purchase order data. Here we selected 00000041 as the purchase order id.

4. Successfully build and run the job.

5. You can see the purchase order total value in the info log as shown below,

How to Calculate purchase order total value using X++ in Dynamics 365 FO?

If this article is useful to you, please try to share it with your friends, if you have any doubts about this article please comment in the comment box.

Published on:

Learn more
D365 Snippets
D365 Snippets

Share post:

Related posts

Model Context Protocol in Microsoft Dynamics 365 CE/CRM: What MCP Means for Sales and Customer Service AI Agents

An AI agent can summarize an account and still miss the detail that matters most. A seller may receive a recommendation without recent service...

4 days ago

Overview Quality Management in Microsoft Dynamics 365 Finance & Operations – Part 1

Why Every Manufacturing Business Needs Quality Management Overview Why Every Manufacturing Business Needs Quality Management Imagine walking i...

13 days ago

Tips to Export Data To Data Lake From MS Dynamics 365 CE And Use It In Power BI.

Integrating Dynamics 365 with Azure Data Lake allows you to continuously sync operational data for cost-effective big data analytics, AI workl...

16 days ago

Copilot Cowork and Dynamics 365 Customer Engagement: What It Means for Sales and Service Teams

Microsoft’s Copilot Cowork update matters because it moves AI closer to daily sales and service work inside Dynamics 365. Sellers, service man...

19 days ago

Beyond Attribution: Pipeline Intelligence from Marketing Activities with Dynamics 365 CE/CRM and Power BI

At New Dynamic, a marketing reporting project evolved into something much larger. What began as an effort to better understand marketing activ...

26 days ago

Why Solution Structure Determines Whether Microsoft Dynamics 365 Customer Engagement Environments Scale Successfully

Many Microsoft Dynamics 365 Customer Engagement environments do not become difficult overnight. The friction builds gradually. Deployments req...

1 month ago

The Revenue Leak Your Dynamics CRM Cannot See

Key Takeaways: 1. The biggest revenue loss in field sales is invisible. It never shows up in a report; it's the nearby visit a rep never knew ...

1 month ago

AI Agents in Microsoft Power Platform: Where Custom Agentic CRM Fits in Dynamics 365 Customer Engagement

In many CRM planning conversations right now, AI agent discussions are starting before organizations have fully aligned governance, integratio...

1 month ago

Business Process Flows in Dynamics 365 CE

Let’s look back at an oldie but a goodie in Dynamics 365 CE/CRM: Business Process Flows! These are designed to standardize how records m...

1 month ago

20 Most Commonly Used JavaScript Scenarios with Sample Code Snippets in Form Script – Dataverse / Dynamics 365 CE

JavaScript plays a critical role in Microsoft Dataverse and Dynamics 365 Customer Engagement (CE) applications. While Power Automate and Busin...

1 month ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy