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 1 Discover 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 Timeline
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 am trying to negate the value to negative based on a condition, and no matter what method I apply to negate it, I get positive value.
Here is the code;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Item Jnl.-Post Line", 'OnAfterInitItemLedgEntry', '', true, true)]
procedure MyProcedure2(ItemJournalLine: Record "Item Journal Line"; var NewItemLedgEntry: Record "Item Ledger Entry")
if NewItemLedgEntry.Positive = true then
NewItemLedgEntry."Carat Wt" := ItemJournalLine."Carat Wt"
if NewItemLedgEntry.Positive = false then
NewItemLedgEntry."Carat Wt" := (ItemJournalLine."Carat Wt") * -1;
Carat Wt is a custom field I created. The value gets passed on fine, but without it being negative. In the second condition, I am multiplying by -1 yet the value gets saved as positive.
Try to subscribe OnBeforeInsert trigger of the Item Ledger Entry table.
Do it on onbeforeinsert event.
You can also use absolute to avoid using if and else.
NewItemLedgEntry."Carat Wt" := Abs(ItemJournalLine."Carat Wt");
Business Applications communities