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

Notifications

Announcements

No record found.

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
    95,729 Super User 2025 Season 2 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans