web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Calculated field on Sales Line table

(0) ShareShare
ReportReport
Posted on by 92

I have created an extension of the table "Sales line", in which I have created a field "Shipped Not Inv. No VAT", which should be the result of the multiplication of two existing fields in the table, "Qty. Shipped Not Invoiced" * "Unit price", this in each line. I have added the operation in the "OnAfterValidate ()" tigger of both fields, but nothing happens.

Also try to do it through a codeunit, following this example: 

https://community.dynamics.com/business/f/dynamics-365-business-central-forum/300617/add-dynamically-calculated-field-to-sales-document-lines

But it doesn't work for me either. Is there something I need to add somewhere?

pastedimage1632439463360v1.png

codeunit 52122 ShipNotInvNoVATPub
{
    trigger OnRun()
    begin

    end;

    [IntegrationEvent(false, false)]
    local procedure OnAfterValidate(var r: Record "Sales Line")
    begin
    end;
}

codeunit 52123 ShipNInvNoVATSub
{
    trigger OnRun()
    begin

    end;

    [EventSubscriber(ObjectType::Table, Database::"Sales Line", 'OnAfterValidateEvent', 'Unit Price', false, false)]
    local procedure UnitPriceChange(var Rec: Record "Sales Line")
    begin
        Rec."Shipped Not Inv. No VAT" := Rec."Unit Price" * Rec."Qty. Shipped Not Invd. (Base)";
    end;

    [EventSubscriber(ObjectType::Table, Database::"Sales Line", 'OnAfterValidateEvent', 'Qty. Shipped Not Invd. (Base)', false, false)]
    local procedure QtyChange(var Rec: Record "Sales Line")
    begin
        Rec."Shipped Not Inv. No VAT" := Rec."Unit Price" * Rec."Qty. Shipped Not Invd. (Base)";
    end;


}

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Calculated field on Sales Line table

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks

  • Suggested answer
    Mohana Yadav Profile Picture
    60,989 Super User 2025 Season 2 on at
    RE: Calculated field on Sales Line table

    OnAfterValidate of field trigger will work when we enter/validate data in that field.

    Please OnAfterGetRecord on Subpage trigger to check if it is working or not.

  • Suggested answer
    Greg Enns Profile Picture
    1,106 on at
    RE: Calculated field on Sales Line table

    Code looks right to me at a quick glance. A few things to try:

    Make sure your extension is published. Restart the nav service tier (not sure how that works in the cloud as I'm on-prem). Run the debugger when changing data in those fields.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,477

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 3,235 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,799 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans