New resources available on Microsoft Learn
Did you know that Microsoft Learn offers free training modules to assist you on your path to mastering Dynamics 365 for Finance and Operations? Become an expert at your own pace or share with your team to foster growth.
Dynamics 365 2019 release wave 2 plan Discover the latest updates to Dynamics 365.Release Plan | Weekly Deployment Notes
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants.Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements.
ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Talent TechTalks
Vey frequently a question is asked, that is how to calculate sales order or PO total by x++ code.
Using standard Dynamics AX you can navigate to any orders and select Totals/ sum button, which will bring you around totals.
Now when it is needed to have totals of any of control document, first look into AOT for built-in classes e.g. SalesTotals, PurchTotals (for purchase total). Using built-in classes is very important as AX involves too many assumptions for calculating total of orders. Just by having sum of lines directly at table may not work perfectly all the time.
Here goes the way to calculate total for sales order:
static void SalesTotalJobTest1(Args _args)
salesTable = SalesTable::find("000746");
salesLine = SalesLine::find(salesTable.SalesId);
salesTotals = SalesTotals::construct(salesTable);
tax = Tax::construct(NoYes::No);
salesAmt = salesTotals.totalBalance();
taxAmount = salesTotals.totalTaxAmount();
discountAmt = salesTotals.totalEndDisc();
totcharges = salesTotals.totalMarkup();
totOfOrder = salesTotals.totalAmount();
contributionRatio = salesTotals.totalContributionRatio();
info(Strfmt("Subtotal Amount %1",salesAmt ));
info(Strfmt("The tax amount is %1",taxAmount ));
info(Strfmt("The Discount is %1",discountAmt ));
info(Strfmt("Charges/ Markup %1",totcharges ));
info(Strfmt("Invoice Amount %1",totOfOrder ));
info(Strfmt("Contribution ratio %1",contributionRatio ));
Keep DAXing !
Business Applications communities