To set up a Dynamics 365 Business Central (BC) data source that filters records modified since the last time the integration ran. The Last modified date field of Items, Customers, Vendors can be used to add an incremental filter condition. I have received several support requests for documented steps to achieve this with SmartConnect.
Configuration
- Create two new Global Variables in SmartConnect and set the default date values to an ISO8601-compliant date format (2020-05-07T12:41:29.000Z).
- GBL_BC_ITEM_DATE
- GBL_BC_ITEM_STAGE_DATE
- Create a Business Central query data source ( I used ItemCard).
- Apply a filter to the query using the “greater than or equal to” condition.
Last_Date_Modified ge GBL_BC_ITEM_DATE
- Create an integration process using the OData query data source.
- Switch to theĀ Tasks tab of the integration.
- Create a new Run Script task as a Task that runs Integration Pre Tasks.
- Write a script to read the current UTC Datetime and format the date in the required destination system date format. Finally, assign it to the variable GBL_BC_ITEM_STAGE_DATE. You can find examples of using Global Variables in Business Central here.
//Store current date in a variable var nd = new Date(); this.GBL_BC_ITEM_STAGE_DATE = nd.toISOString(); return true;
- Save the task.
- Add a new Script Task to Tasks that run if the integration Post Success Tasks.
- Set the script value to update the GBL_BC_ITEM_DATE variable with the value of the GBL_BC_ITEM_STAGE_DATE.
//assign staging date to variable used in source filter this.GBL_BC_ITEM_DATE = this.GBL_BC_ITEM_STAGE_DATE return true;
- Switch to the Variables tab.
- Edit the GBL_BC_ITEM_DATE.
- Check the box for Persist Run Value.
Conclusion
This configuration will create a Dynamics 365 Business Central data source that filters records modified since the last time the integration ran.