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

error "revert the changes" showing on back button after saving data on card page

(0) ShareShare
ReportReport
Posted on by 305

Hi

I have an extension in which data is entered in card page lookup fields (using onLookup trigger). When I select the field value, the status of page shows "Saved" but when I hit the back button, an error message is thrown forcing to revert the changes. After selecting 'revert the changes", the saved lookup field is reset automatically. To my surprise, when I repeat the same sequence of actions, it works fine with saving the same value in the field. 

I am attaching the screenshot of the error messages here.

Please suggest the possible causes.

Thanks in advance

Khudeja

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Hi,

    Looks like you are trying to modify the same record twice at the same time from different places or trying to put invalid value through code.

    You can make use of COMMIT function to write the values to the database.

    Kindly provide your code so we can point out what is going wrong.

  • khudeja Profile Picture
    305 on at

    Hi

    Thanks for responding!

    Below is my code snippet of the lookup field:

    (Employment Code is the lookup field,

    EmploymentDetailsTable is the table name from where the lookup points.)

    field("Employment Code"; "Employment Code")

               {

                   ApplicationArea = All;

                   Enabled = ValidRecord;

                   trigger OnLookup(var Text: Text): Boolean

                   var

                       EmploymentDetailsTable: Record EmploymentDetailsHeader;

                       EmploymentDetailsListPage: Page EmploymentDetailsList;

                   Begin

                       EmploymentDetailsTable.RESET;

                       EmploymentDetailsTable.SETFILTER(EmployeeNo, "No.");

                       CLEAR(EmploymentDetailsListPage);

                       EmploymentDetailsListPage.SETRECORD(EmploymentDetailsTable);

                       EmploymentDetailsListPage.SETTABLEVIEW(EmploymentDetailsTable);

                       EmploymentDetailsListPage.LOOKUPMODE(TRUE);

                       IF EmploymentDetailsListPage.RUNMODAL = ACTION::LookupOK THEN BEGIN

                           EmploymentDetailsListPage.GETRECORD(EmploymentDetailsTable);

                           "Employment Code" := EmploymentDetailsTable.No;

                       END

                   END;

               }

    Please let me know if you need more information for inspecting.

    Regards

    Khudeja

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

    Hey

    I think instead of doing this, why can't you make use of TableRelation property.

    Regards

    Avinash B

  • khudeja Profile Picture
    305 on at

    Hi Avinash,

    I want that on lookup, a filtered view of Employment Details list should open wrt the current employee record (please note that the Employment Code lookup is on the Employee Card). Moreover there are multiple employment details related to a single employee from which one can be selected. Therefore I implemented this code. Can I achieve the same using TableRelation property? Please suggest.

    Regards

    Khudeja

  • khudeja Profile Picture
    305 on at

    Hi,

    Do you see anything in the code that may help resolving the problem?

    Regards,

    Khudeja

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Hey,

    On thing I noticed is you are using OnLookup Trigger. I think you should be using OnDrillDown trigger as I do not fully understand it parameters and I use DrillDown personally.

    One more thing you can give it a try is create another variable pointing to the same table and instead of using "Employment Code" using the

    Rec_TableName."Employment Code" := EmploymentDetailsTable.No; a

    Rec_TableName.Modify(true);

    CurrPage.Update;

    Hope this helps

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

    Hi

    try this way using TableRelation

    EmploymentDetailsTable.No WHERE ("No."=FIELD(EmployeeNo))

    I hope the field "No" in EmploymentDetailsTable is also a primary key.

    Otherwise, i feel by using CurrPage.Update must solve your issue.

    Regards

    Avinash B

  • Suggested answer
    Olister Rumao Profile Picture
    4,009 on at

    Hi Khudeja,

    Avinash's code can work only in the case where the field you are looking for is the primary key in the Lookup Table. If that is not the case then you can proceed with drill down.

    Also, add the COMMIT statement after Modify statement just that your data written down to database and then use CurrPage.Update.

    Let me know if you need help.

  • Shristi Profile Picture
    25 on at

    Am facing the same issue with the code

    Chargeable - OnValidate()

    IF JobTask.GET("Job No.","Job Task No.") THEN BEGIN

     IF (Chargeable=TRUE) AND (JobTask."Line Type"=JobTask."Line Type"::"Non-Billable") THEN

         ERROR(Text50001);

     IF (Chargeable = FALSE) AND (JobTask."Line Type"=JobTask."Line Type"::Billable) THEN

        ERROR(Text50002);

    END

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

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 624 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 440 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 244 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans