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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Best way to use Trigger Events to initiate some kind of action on a table field whose value is calculated?

(0) ShareShare
ReportReport
Posted on by 60

This question probably has an obvious answer but it eludes me, so I'd appreciate help...

With only (2?) available triggers at the (table) field level (each of which require user intervention), how can I do the following in a simple way using Trigger Events?

Let's call 4 fields A, B, C, & D.

  • The user enters something in Field A.
    • I use an OnValidate Trigger Event (of A) to Calculate a value for Field B.
  • I'd like the change in value of B to Initiate an event and change the value of Field C.
  • I'd then like to use the change in value of C to Initiate an event and perform some math to calculate the value of Field D.

Thanks in advance.

I have the same question (0)
  • antmas Profile Picture
    60 on at

    Update... This now works using OnModify Table Trigger Event so that the calculations work just before page is closed.

    If anyone has a more efficient way, please do share. thx

  • Suggested answer
    YUN ZHU Profile Picture
    100,212 Super User 2026 Season 1 on at

    Hi, Can you try the following?

    tableextension 50100 MyExtension extends item
    {
        fields
        {
            field(50000; A; Code[20])
            {
                DataClassification = CustomerContent;
            }
            field(50001; B; Code[20])
            {
                DataClassification = CustomerContent;
            }
            field(50002; C; Code[20])
            {
                DataClassification = CustomerContent;
            }
            field(50003; D; Code[20])
            {
                DataClassification = CustomerContent;
            }
        }
    }
    
    codeunit 50100 MyCodeunit
    {
        [EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterValidateEvent', 'A', false, false)]
        local procedure MyProcedureA(var Rec: Record Item; var xRec: Record Item)
        begin
            Rec.Validate(B, 'Test');
        end;
    
        [EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterValidateEvent', 'B', false, false)]
        local procedure MyProcedureB(var Rec: Record Item; var xRec: Record Item)
        begin
            if Rec.B <> xRec.B then
                Rec.Validate(C, 'Test2');
        end;
    
        [EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterValidateEvent', 'C', false, false)]
        local procedure MyProcedureC(var Rec: Record Item; var xRec: Record Item)
        begin
            if Rec.C <> xRec.C then
                Rec.Validate(D, 'Test3');
        end;
    }

    Hope this will help.

    Thanks.

    ZHU

  • antmas Profile Picture
    60 on at

    ZHU, Thank you for your suggestion.

    I will try this today, then reply afterward.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,012 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 986 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 659 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans