Check out the latest Business Central updates!Learn about the key capabilities and features of Dynamics 365 Business Central and experience some of the new features.
Download overview guide | Watch Business Central video
2020 release wave 1Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 TimelineWatch the 2020 Release Wave 1 virtual launch event
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 TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I have a custom table that I want Posted Sales Invoice header records to be in. So, Sales Invoice Header table to myowntable.
Now, on the OnAfterInsert trigger of the Sales Invoice Header table I wrote the following code so that once a new record is created in the Sales Invoice Header table it get copied over to myowntable. All seems ok except that Amount and Amount Including VAT shows 0.00 in myowntable. All other fields i.e. No.,Sell-to Customer no., Due Date.. All gets copied expect Amount and Amount Including VAT.
Because the amount and amount including VAT are flowfield.
Do calcfields before copying the amounts.
CALCFIELDS("Amount","Amount Including VAT");
Amount and "Amount Including VAT" are both flowfields, which means they don't store a value, but a formula and you need to use Calcfields function to get a value from these fields.
There are two options you have:
1. declare those two fields in your table as decimals, run a Calcfields on them in the original table before copying over to your own.
2. alternatively you can declare them as flowfields as well and calculate the value based on the original lines, or if you have your own copied lines table.
Amount is calculated as: "CalcFormula = Sum ("Sales Invoice Line".Amount WHERE("Document No." = FIELD("No.")));"
"Amount Including VAT" is calculated as: CalcFormula = Sum ("Sales Invoice Line"."Amount Including VAT" WHERE("Document No." = FIELD("No.")));
All the best,
Please verify my answer, if you find it useful, that way others can find this solution easier!
Did not work.
1) declare those two fields in your table as decimals, run a Calcfields on them in the original table before copying over to your own.
My table has them both as Decimal and here is what I tried but it did not seem to work.
recProof: Record "Proof of Delivery";
CALCFIELDS(Rec."Amount", Rec."Amount Including VAT");
with recProof do begin
recProof."Sell-to Customer No." := Rec."Sell-to Customer No.";
recProof."Due Date" := Rec."Due Date";
recProof.Amount := Rec.Amount;
recProof."Amount Including VAT" := Rec."Amount Including VAT";
recProof."Currency Code" := Rec."Currency Code";
recProof."Remaining Amount" := rec."Remaining Amount";
recProof."Location Code" := rec."Location Code";
That's because at this stage you have no lines created yet.
So you'll have to use the second option, or if you want the real values do it on codeunit 80 trigger when the invoice gets posted.
Or if you want the real values subscribe to something like onafterpost (or similar) on codeunit 80 trigger after the invoice gets posted, then the lines are created as well.
Business Applications communities