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

Run code After modification or insertion

(0) ShareShare
ReportReport
Posted on by 70

I have created my own custom table in business central.

I have a scenario in which i need to run a code after a record is successfully inserted or modified through a page.

I need to update values to second table depending upon the values after inserted or modified in the page.

There are method such as 

 trigger OnAfterInsert()
trigger OnAfterModify()
But these works on on table extension. I have to perform the same but on my custom table.
How can i achieve this.
( i am using page to insert or modify record).
Not sure which method to use on page or table which executes after insert or modify.
 
I have the same question (0)
  • Daniel Rimmelzwaan Profile Picture
    3,485 on at
    RE: Run code After modification or insertion

    Data related logic should never reside on page objects. Table objects have their own triggers, you are looking for OnInsert and OnModify triggers at the table level. Here's a screenshot of where you put those triggers:

    pastedimage1589417086362v1.png

    I guess if you want to really do something AFTER insert/modify, you could add an event subscriber to a codeunit, and subscribe to the table's events. Create a new codeunit and start the 'teventsub' snippet, that should be self explanatory. There are OnBefore and OnAfter events for both Insert and Modify.

    pastedimage1589417633221v1.png

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,160

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,943

#3
Sumit Singh Profile Picture

Sumit Singh 2,823

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans