How to: Business Central & OData v4

Dynamicweb allows for data integration with Dynamics365 Business Central through dedicated OData V4 endpoints.

The following guide explains how to set up OData V4 integration between Business Central and Dynamicweb.

The first step required in OData integration is setting up the relevant endpoints in Settings > Integration > Endpoint Management > Add endpoint.

Specific endpoints for each object type must be set up, but for the sake of simplicity, this guide continues with the endpoint for importing products as an example.

For a more detailed guide on importing each specific object type, click here.

To add an endpoint, follow these steps:

  • Provide the endpoint with a Name and an optional Description.
  • Insert OData v4 URL from Business Central Web Services.
  • Set Type to GET
  • Choose Endpoint Authentication at the bottom of the page*
  • Save and close.

*There are several authentication methods available. You can access documentation on the different possibilities here. Endpoint authentications can be managed in Settings > Integration > Endpoint Management.

Figure 2.1 Adding an endpoint in Endpoint management

Scroll to the bottom of the page to choose the endpoint authentication.

Figure 2.2 Choosing endpoint authentication at the bottom of the "Add endpoint" page.

When using OData integration, you might not be interested in importing every record of a given object type.

To filter in the imported data, you can add one or more query parameters to the endpoint.

A query parameter consists of a key and a value such as the examples in the table below.

Key

Value

Description

$filter

Startswith(Item_No,’IN1’)

Filters the data provided by the endpoint, so that only records where the Item_No attribute starts with the string IN1 is included.

$top

10

Only selects the first 10 records of the object type.

 

Once a query parameter has been added to the endpoint and the endpoint itself has been saved, the full URL (including the added query parameter) will be visible in the endpoint editor.

There are many more ways to filter the OData provided by the endpoint.  A complete documentation for OData filter expressions can be found here:

When the endpoint has been set up, the next step is to add an integration activity in Settings > Integration > Data Integration > New Activity.

  • For the Source setting choose Type: “Endpoint provider”.
  • Select the "OData v4 - Business Central" as the Endpoint Type.
  • Select the predefined endpoint from the dropdown menu.
  • Select the desired Mode under Advanced activity settings. Please refer to the table below for an elaboration on the modes.
  • maximum page size* and limitations to the request timeout** can be applied at the bottom of the page.
  • Click next.

*Maximum page size allows you to set the maximum number of records on each page, if the value is set to zero it will use the default page size of Business Central.

**The value applied in Request timeout sets a timer on how long the activity is allowed to run before it is automatically aborted.

 

  • For the Target setting choose Type: “OData provider”.
  • Select the desired Object Type from the dropdown menu in Parameters > destination > object type.
  • Depending on the chosen object type more specific Object type settings may be available. For a more detailed documentation on the required settings for the specific object type imports. Click here.
  • Click next.
  • Select the source table to import from. The mapping to the target table will be auto selected by Dynamicweb.
  • Click finish.
  • Finally, provide the activity with an optional description and click OK.

When the activity has been added, the settings menu for the activity depicted below will be visible. This menu can be accessed at any time by clicking the activity in Settings > Integration > Data Integration.

The four modes available for the activity settings include the following:

Delete This mode compares primary keys between records in the endpoint and in Dynamicweb. Records in Dynamicweb that do not appear in the endpoint will be deleted.
Delta replication By locating the time of the last succesful run this mode will import new records only. No records are deleted from Dynamicweb when this mode is used.
First page Imports the first page of records only. The maximum amount of records on a page is specified in the maximum_page_size setting.
Full replication This mode imports all records and deletes nothing in Dynamicweb. Activities with this mode should only be run once.

 

In this view the table mappings of the activity can be managed. The mappings are auto selected for all non-custom activities in Dynamicweb.

To finish the activity setup, press save and close or save and run to perform the import job immediately.

To make sure all imported data is stored with the correct relations in the Dynamicweb database, the import activities should be run in the following order:

You can click each object type to acces specific documentation on each of them.

Import order

Dynamicweb object type

Business Central object name

Business Central object ID

1

Country

Countries/Regions

10

2

Currency

Currencies

5

3

User salesperson

Salesperson/Purchaser Card

5116

4

User

Contact Card

5050

5

User customer

Customer Card

21

6

User address

Contact Alt. Address Card

5056

7

User customer ship-to address

Ship-to Address

300

8

Manufacturer

Vendor Card

26

9

Stock location

Locations

15

10

Product group

Item Category Card

5733

11

Product

Item Card

30

12

Product variant

Item Variants

5401

13

Product unit

Units of Measure

209

14

Product-unit relation

Item Units of Measure

5404

15

Product translation

Item Translations

35

16

Product unit translation

Unit of Measure Translation

5402

17

Stock amount

Stockkeeping Unit Card

5700

18

Order

Sales Order

42

19

Custom

 

 

 

Please note that while the object types of country and currency do appear first in the order list, it might not be necesarry to run them as actual OData import jobs. Simply adding them manually in Dynamicweb may suffice while also preventing unnecessary country records of the ERP from being imported.

The first step in exporting data with the OData provider is setting up the endpoint in:

Settings > Integration > Endpoint management > Add Endpoint.

Specific endpoints for each object type must be set up, but for the sake of simplicity, this guide continues with the endpoint for exporting customers as an example.

For a more detailed guide on importing each specific object type, click here.

  • Provide the endpoint with a Name and an optional Description.
  • Insert OData v4 URL from Business Central Web Services
  • Set Type to POST
  • Choose Endpoint Authentication at the bottom of the page.*
  • Save and close

 

*An endpoint authentication can either be a WebServiceAccesKey or OAuth. Endpoint authentications can be managed in Settings > Integration > Endpoint Management.

To make sure all exported data is stored with the correct relations in Business Central, the export activities should be run in the following order:

Export order

Dynamicweb object type

Business Central object name

Business Central object ID

1

User customer

Customer Card

21

2

User

Contact Card

5050

3

User address

Contact Alt. Address Card

5056

4

User customer ship-to address

Ship-to Address

300

5

Order

Sales Order

42

 

When the endpoint has been set up, the next step is to add an integration activity in Settings > Integration > Data Integration > New Activity.

  • For the Source setting choose Type: “OData provider”.
  • Select the relevant object type under parameters > source object type.
  • Depending on the chosen object type more specific Object type settings may be available. For a more detailed documentation on the required settings for the specific object type imports. Click here.
  • For the Target setting choose Type: “Endpoint provider”.
  • Select the destination endpoint from the dropdown menu.
  • Click next.
  • Select the source table to export. The mapping to the target table will be auto selected by Dynamicweb.
  • Click finish.
  • Finally, provide the activity with an optional description and click OK.

When the activity has been added, the settings menu for the activity depicted below will be visible. This menu can be accessed at any time by clicking the activity in Settings > Integration > Data Integration.

 

In this view the table mappings of the activity can be managed. The mappings are auto selected for all non-custom activities in Dynamicweb.

To finish the activity setup, press save and close or save and run to perform the import job immediately.