Company Data Exchange AE100


General Description #

This extension simplifies copying specific data between multiple companies. It allows creating templates that specify which data are to be copied, and assigning companies to templates. The template describes what fields of which tables should be copied. It also allows to filter the records, and to specify actions to be executed when copying records.

The copying is done using the Copy action on the Central Mapping Template List page. It copies all the data specified in the template into the selected companies. Only the data more recent than Last Copy Datetime will be copied into any given company.

Report Copy Data via Central Mapping (80024) can be used to run the Copy action for all central mapping templates.

Setup #

New templates are specified and assigned on Central Mapping Template List page. Each company keeps track of the datetime when the data was last copied to it (Last Copy Datetime), and it's possible to toggle if the data should be copied into the selected company (Copy).

Clicking on Name of the template will open the Central Mapping Template Card page, where the tables to be copied from are specified. For each table it's possible to specify which action should be taken if the copied record already exists in the target company. Additionally it allows to specify whether the "OnInsert" trigger should run after copying new record and whether the "OnModify" trigger should run after copying new values into existing record.

The Filters action on the Central Mapping Template Card page is used to filter the records of the selected table. The Fields action on the same page opens the Central Mapping Table Fields page, which allows to specify the fields that should be copied.

On the Central Mapping Table Fields page it's also possible to specify whether "OnValidate" trigger should run after copying field value. For each table specified in Central Mapping Template Card there must be at least one field in Central Mapping Table Fields. Using the Insert all fields action on Central Mapping Table Fields page inserts all the fields from table specified by Table Name into this page.

API setup #

If the Company Type is Local, no further setup is needed. If it is Remote, it is first needed to register an application in Azure Active Directory as it will be used for OAuth 2.0 authentication of the API calls. More information can be found here.

In both the source and target company, REST Authentication must be created using the client ID and client secret of the registered application. The Scope must be set to https://api.businesscentral.dynamics.com/.default and Access Token URL to https://login.microsoftonline.com/<tenant-name>/oauth2/v2.0/token

In the target company in Business Central it is needed to add Azure Active Directory Applications using the client ID of the application registered in the first step and to assign permissions for objects that will be accessed via API. Report 80022, which processes the received messages, must be added to the job queue as a recurring job.

In the source company on the Central Mapping Template List, the following fields must be specified:

  • API Service URL - URL used to connect to the API of the target company
  • API Service Authentication Code - code of the REST Authentication used to connect to API of target company
  • API Callback URL - API URL of source company
  • API Callback Authentication Code - code of the REST Authentication used by the target company to send feedback to source company

Copying of data from source company can be automated by adding report 80024 as a recurring job to job queue of the source company.

In case of an error, received messages can be processed manually in the target company, or deleted if the error cannot be resolved. Likewise, the sent messages can be deleted in the source company.