Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Code architecture for a simple copy data routine

Posted on by 9
Dear Community,
 
I came from a different programming language and I am new to AL.
 
For an interface between BC and a MES System I want to catch all changes on the Production Order Line Table and copy these changes to a separate table. Later, I want to make them accessible via REST.
 
I am wondering which of the following architectures would be the most AL typic approach:
 
Solution one:
1. Writing a Codeunit that does the Copy Job i. e. transferring data from production order line table to the new table
2. Calling these Codeunit from the OnInsert, OnModify, etc. Triggers at the production order line Table.
 
Solution two:
1. Writing a Codeunit that does the Copy Job i. e. transferring data from production order line table to the new table
2. Extending this Codeunit with an EventSubscriber that is listening on Prod. Order Line Table.
 
I appreciate your help!
Categories:
  • CaseTree Profile Picture
    CaseTree 9 on at
    Code architecture for a simple copy data routine
    Thank you for your response. I checked the tables. However, I could not found the mentioned fields. I guess these tables (e. g. production order line) do not have these fields, do they?
     
    Notwithstanding your suggestion, would be solution one or two more al like?
     
    Thank you for help!
     
    Best regards
  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,746 Super User 2024 Season 1 on at
    Code architecture for a simple copy data routine
    For this I do not think that i would use any of the approaches that you suggest.
     
    On all the tables in Business Central there are a system created at (datetime) and sysstem modified at (datetime) field. 
    So I think the best approach would be to make a codeunit that could run in a jobscheduler that copied the needed data to a separate table on a schedule f.ex. once every hour or so.
     
    You could also publish the table directly and let the recieving system keep track of what is the last datatime they have handeled modifications from and let them filter on that in their query.
     
    Then you would not have to duplicate any data at all.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,275 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans