Today I will post a piece of code used to get the purchase order total value.
This value can also be found on Totals form, which can be accessed through:
Accounts payable/Common/Purchase orders/All purchase orders/Tab – Purchase Order/Group – View/Totals
How to get it through X++, in this example I have created a new Job.
static void _GetPurchTotalAmount(Args _args)
{
PurchTotals purchTotals;
PurchTable purchTable = PurchTable::find('000023');
DiscAmount discAmount;
;
purchTotals = PurchTotals::newPurchTable(purchTable);
purchTotals.calc();
discAmount = purchTotals.purchTotalAmount();
setPrefix('Purchase Order');
info(strFmt('%1 - Total Value: %2', purchTable.PurchId, discAmount));
}
Result:

Like
Report

*This post is locked for comments