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 :
Business Central forum

Retrieve latest modified records in tables for Integration

(0) ShareShare
ReportReport
Posted on by 25

Hi,

I am performing an Asynchronous integration of third party system with business central.I have written a code unit that is exposed as web service. which will be used by the 3rd party system 
i am syncing the following entities.

1. Product with Product variants and product identifiers
2. Sales order header with sales line.
3. sales shipment header with sales shipment line
4. sales invoice header with sales invoice line.

In my scenario i have multiple jobs which executes multiple time in a day that find the set of record which are changed after the given date-time. Then sync only the records which were changed.

Now the problem i am facing is that in business central most of the tables doesn't have modified date time field, which can be used to filter the records that are modified recently.

Can anyone tell me how i can filter the records from any table that are modified recently?

Note :

One of the possible solution is to extend each table add a new field modified date-time. Extend the onmodify() trigger and set the current date-time on it.
But my client doesn't prefer to extend all of these tables just for a very basic field.

The other solution i have identified is to use the change log feature.But i believe this will slow down the system due to large numbers of records.

Thanks.

Zuhad Mahmood

Categories:
  • Suggested answer
    I Gusti Made Ari Profile Picture
    3,608 on at

    Best Practice is to expose the timestamp field in the table and use this field to identify your last synchronization.

    Check below link on how to do that :

    docs.microsoft.com/.../how-to--use-a-timestamp-field

  • ZUHAD MAHMOOD Profile Picture
    25 on at

    Hi Sir,

    [quote user="I Gusti Made Ari"]

    Best Practice is to expose the timestamp field in the table and use this field to identify your last synchronization.

    Check below link on how to do that :

    docs.microsoft.com/.../how-to--use-a-timestamp-field

    [/quote]

    I have just reviewed the time stamp property.The AL is not allowing to enable it on table extension. Is there any other way to enable it? I am using the business central cloud sandbox .
    5556.Capture.PNG

    Thanks,

    Zuhad Mahmood

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,306 Super User 2026 Season 1 on at

    The sql time stamp property is only allowed in new table, not table extension.

    Just add a new field called Modified Date Time and update that field OnInsert and OnModify.

    Either way, you will end up with extension.

    Also the SQL time stamp is not a real date and time. It is an big integer. Not sure if your requirement can benefit from it or not.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    Insert/Last Modified date field to tables exposed by standard D365BC APIs will be added in the near future. Actually not all entities have those field.

    A possible way without involving extensions that adds these missing fields to standard tables is using Webhooks. With webhooks, you can subscribe to entities and then receive a notification when something has changes:

    https://community.dynamics.com/business/b/businesscentraldevitpro/posts/webhooks-don-39-t-call-us-we-will-call-you

  • ZUHAD MAHMOOD Profile Picture
    25 on at

    I have checked the web hooks but it ain't helpful in my scenario so i ended up to adding a new field called Modified Date Time and update that field OnInsert and OnModify.

    Thanks

  • DARRA Profile Picture
    40 on at

    Zuhad, could you please share with me the code that you used to set the Modified Date Time field and update it with  OnInsert and OnModify

  • DARRA Profile Picture
    40 on at

    This is the code I am using, but it doesn't seam to work , any suggestions?

    tableextension 80101 TimeStamp extends "Sales Invoice Line"

    {

       fields

       {

           field(8110; "Modified Date Time"; Date)

           {

               Editable = false;

           }

       }

       trigger OnInsert();

       begin

       end;

       trigger OnModify();

       begin

       end;

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    Inside those OnInser and OnModify triggers, you need to fill your field, so:

    ”Modified Date” := CURRENTDATETIME;

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    If it’s only a date field, use:

    “Modified Date” := TODAY;

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 > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans