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...
Answered

Maintain a flag on updating a record

(0) ShareShare
ReportReport
Posted on by 700

Hi All,

How to maintain a flag when a record is manually updated in Business Central.

In my case, I have to maintain a flag on 'Manager Time Sheets' page when a record in time sheet (i.e. Time) is manually updated.

Could anyone please suggest a solution.

pastedimage1573121202590v1.png

Thanks in advance !

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    You can use OnModify trigger of the table.

    The CurrFieldNo is the variable which stores the Field No. of the table from which the record is getting modified.

    For Ex.

                If CurrFieldNo = FieldNo("Respective field name") then

                    "Record Modified" := true;

    Regards

    Avinash B

  • Dynamics 365 Business Central Profile Picture
    700 on at

    tableextension 50123 ManagerTimeSheetTableExtension extends "Time Sheet Line"

    {

       fields

       {

           // Add changes to table fields here

       }

       trigger OnModify()

       var

           myInt: Integer;

       begin

           If CurrFieldNo = FieldNo() then

               "Record Modified" := true;

       end;

       var

           myInt: Integer;

           mgr: Page "Manager Time Sheet";

           "Record Modified": Boolean;

    }

    Is the above code correct ?

    I am not getting, what should be passed to FieldNo(). Intellisense is not showing the fields which are getting updated.

    Please help.

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    FieldNo() is a procedure, you must pass the Field Name as a parameter.

    Like, if you want to make the boolean on modifying of field "Time Sheet Starting Date" then

    If CurrFieldNo = FieldNo("Time Sheet Starting Date") then
        "Record Modified" := true;

    Meaning, the modified field value is based on the field number specified the field in the FieldNo parameter, then makes the boolean true.

    Regards

    Avinash B

  • Dynamics 365 Business Central Profile Picture
    700 on at

    As you can see in the screenshot, I have to modify the fields in which time is specified corresponding to dates, but it is not being accepted as a parameter.

    Can you please check the 'Time Sheet Line' table once, you will get my issue !

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    The data is not storing in the Time Sheet Line record.

    So I suggest you use Subscribers and you can achieve this.

        [EventSubscriber(ObjectType::Page, Page::"Time Sheet", 'OnAfterValidateEvent', 'Field1', true, true)]
        local procedure MyProcedure(var Rec: Record "Time Sheet Line"; var xRec: Record "Time Sheet Line")
        begin
            //Get time sheet header rocord and modify the triger
            // you may have to write this subscriber for Field1..Field7
        end;

    Regards

    Avinash B

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Where to put this code? In the table extension ?

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Create a new codeunit and set the EventSubscriberInstance property of the codeunit to StaticAutomatic.

    In new codeunit you can create these events.

    Regards

    Avinash B

  • Dynamics 365 Business Central Profile Picture
    700 on at

    So, I have to do :

    1. Creation of codeunit, as you told

    2. The OnModify() trigger on the tableext

    Correct me if I am wrong

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Sorry to say, but I don't know how to write this procedure.

    Is it possible for you to help, only if you can !

  • Dynamics 365 Business Central Profile Picture
    700 on at

    codeunit 50100 EventSubscriberCodeunit

    {

       EventSubscriberInstance = StaticAutomatic;

       [EventSubscriber(ObjectType::Page, Page::"Time Sheet", 'OnAfterValidateEvent', 'Field1', true, true)]

       local procedure MyProcedure(var Rec: Record "Time Sheet Line"; var xRec: Record "Time Sheet Line")

       begin

           //Get time sheet header rocord and modify the triger

           // you may have to write this subscriber for Field1..Field7

           If CurrFieldNo = Rec_TimeSheetLine.FieldNo("Field1") then

               "Record Modified" := true;

       end;

       // end;

       var

           myInt: Integer;

           "Record Modified": Boolean;

           Rec_TimeSheetLine: Record "Time Sheet Line";

           CurrFieldNo: Integer;

    }

    Is it correct ?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 755 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 413 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 387 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans