Difference between revisions of "Business Central"

From Resco's Wiki
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{WIP}}
 
 
{{Wikipedia|Microsoft Dynamics 365 Business Central}}
 
{{Wikipedia|Microsoft Dynamics 365 Business Central}}
 
'''Microsoft Dynamics 365 Business Central''' is an enterprise resource planning system from Microsoft. The product is part of the Microsoft Dynamics family.
 
'''Microsoft Dynamics 365 Business Central''' is an enterprise resource planning system from Microsoft. The product is part of the Microsoft Dynamics family.
Line 6: Line 5:
 
* Via [[Power Automate]] + Resco Cloud connector: full-featured integration using a '''third-party''' Microsoft service
 
* Via [[Power Automate]] + Resco Cloud connector: full-featured integration using a '''third-party''' Microsoft service
 
* Using [[Integrations]] (Preview): connect your Resco Cloud organization to Business Central '''directly''' from Woodford.
 
* Using [[Integrations]] (Preview): connect your Resco Cloud organization to Business Central '''directly''' from Woodford.
 +
 +
This article explains the second method in more detail.
  
 
[[File:Connect to business central directly from resco cloud.png|600px]]
 
[[File:Connect to business central directly from resco cloud.png|600px]]
 
This article explains the second method in more detail.
 
  
 
== Register Resco application in Business Central ==
 
== Register Resco application in Business Central ==
Line 19: Line 18:
 
# As '''Client ID''', use <code>4abedb2f-19bc-402f-b0b5-b8d17e85aa04</code>.
 
# As '''Client ID''', use <code>4abedb2f-19bc-402f-b0b5-b8d17e85aa04</code>.
 
# Add '''User Permission Sets''' (<code>SUPER</code>).
 
# Add '''User Permission Sets''' (<code>SUPER</code>).
# Grant the necesary consent.<br>[[File:Bc3.png|600px]]
+
# Grant the necessary consent.<br>[[File:Bc3.png|600px]]
  
 
== Install Resco extension on Business Central ==
 
== Install Resco extension on Business Central ==
  
The extension is required for synchronizing between Resco Cloud and Business Central.
+
The extension is required (but see below) for synchronizing between Resco Cloud and Business Central.
# Download the extension from [https://rescocloud.blob.core.windows.net/integrations/Resco_RescoIntegrations_1.0.0.0.zip Resco web].
+
# Download the extension from [https://rescocloud.blob.core.windows.net/integrations/Resco_RescoIntegrations_1.0.0.1.zip Resco web].
 
# Log in to Business Central and search for "extensions".<br>[[File:Install extension 1.png|600px]]
 
# Log in to Business Central and search for "extensions".<br>[[File:Install extension 1.png|600px]]
 
# On the '''Manage''' tab, click '''Upload Extension''' and upload the zip file.<br>[[File:Install extension 2.png|600px]]
 
# On the '''Manage''' tab, click '''Upload Extension''' and upload the zip file.<br>[[File:Install extension 2.png|600px]]
 
# Open Web Services, click New, select Page, select RescoCustomer and write RescoCustomer as Service Name.
 
# Open Web Services, click New, select Page, select RescoCustomer and write RescoCustomer as Service Name.
 
# Repeat it for every custom page from the Resco extension. (RescoCustomer, RescoContact, RescoServiceOrder).
 
# Repeat it for every custom page from the Resco extension. (RescoCustomer, RescoContact, RescoServiceOrder).
 +
 +
=== Can I integrate without extension? ===
 +
 +
Yes, but... it depends on your customization of Business Central.
 +
 +
The integration offers two modes of synchronization:
 +
* Full sync: download all records of an entity.
 +
* Incremental sync: download only changed records.
 +
 +
To take advantage of the faster, incremental sync, Business Central must have a Version Number field on the entity; and this field must be defined in the mapping in Woodford.
 +
 +
[[File:Version number.png|600px]]
 +
 +
You can define the version number using the extension. We recommend using row version number (Big Integer) as the Version number field. You can use Date/DateTime fields as well, but it won't be 100% incremental sync.
  
 
== Create integration ==
 
== Create integration ==
Line 36: Line 49:
 
#* Name - enter a name of your integration
 
#* Name - enter a name of your integration
 
#* Connector - select OData
 
#* Connector - select OData
#* URL - enter the URL of Business Central OData endpoint (e.g., https://api.businesscentral.dynamics.com/v2.0/b8cc0002-2542-46ed-8584-d4868701fbc4/Production/ODataV4/)
+
#* URL - enter the URL of Business Central OData endpoint (e.g., <code><nowiki>https://api.businesscentral.dynamics.com/v2.0/b8cc0002-2542-46ed-8584-d4868701fbc4/Production/ODataV4/</nowiki></code>)
 
#* Username - BC account's email address
 
#* Username - BC account's email address
 
#* Password - BC account's password
 
#* Password - BC account's password
Line 42: Line 55:
 
# Click '''Save'''.
 
# Click '''Save'''.
  
== Configure integration ==
+
You have created the integration; you can now set it up.
 +
 
 +
== Customize integration ==
 +
 
 +
=== How to change default mapping? ===
 +
 
 +
Mapping allows you to match entities and fields on Business Central with entities and fields on Resco. Out of the box, three entities are mapped and ready for synchronization: account, contact, and work order.
 +
 
 +
# Double-click the integration.
 +
# Select an entity on the External Entities pane (left).
 +
# Select the matching local entity, its primary key, and version number.
 +
# In the table below, define the mapping for fields that you want to integrate: select the checkbox and choose a matching '''Local Field'''.
 +
# For all fields with the local type Lookup, enter the lookup '''Target''' in this format: <code>[localEntity].[localField]</code> (e.g., <code>account.integration_bc_pk</code>).
 +
# Save all changes.
 +
 
 +
=== How to enable/disable entity for synchronization? What if I only want to upload or download? ===
  
# Double-click this integration to map external entities/fields to local entities/fields. For Business Central, some settings are configured by default:
+
# Double-click the integration.
#* Default mapping will be added. In the preview, only three entities are officially supported: account, contact, and work order.
+
# Select an entity from the '''External Entities''' pane.
#* Based on default mapping, External Primary Key fields will be added to the schema.
+
# Click '''Enable''' or '''Disable'''.
# Verify that the three entities supported out-of-the-box are enabled.
+
# Use '''Sync Direction''' to control if you want to exchange data in both direction, upload only, or download only.
 
# Save all changes.
 
# Save all changes.
  
You can start migrating or synchronizing data:
+
=== How to change Sync Filter? ===
* [[Integrations#Set_up_sync_filter|Set up sync filter]]
+
 
* [[Integrations#Import.2Fexport_data|Import/export data]]
+
If you want to restrict what data to sync, consider setting up a [[Sync Filter]].
* [[Integrations#Synchronize_data|Synchronize data]]
+
 
 +
# Double-click the integration.
 +
# Select an entity from the '''External Entities''' pane.
 +
# Click '''Download Filter''' or '''Upload Filter'''.
 +
# Enter custom conditions that serve as a filter for records.
 +
# Save all changes.
 +
 
 +
=== Can I sync two external entities with one entity on Resco Cloud? ===
 +
 
 +
The schema of the external system can be vastly different from your Resco Cloud organization. Fortunately, you can map two (or more) external entities to a single Resco Cloud entity. Use upload sync filter to ensure that the correct records from Resco Cloud end up in the right entity on the external system.
 +
 
 +
[[File:Multiple entities.png|600px]]
 +
 
 +
=== How to add a new entity to integration? ===
 +
 
 +
Synchronization is effective if the versionnumber of entity (table in Business Central) is compared from the last sync. Therefore we recommend creating a table extension to access field(0) - versionnumber in Business Central.
 +
 
 +
This is an example of an extension for the Customer table. Apply the same principles to other tables.
 +
 
 +
<syntaxhighlight lang="pascal">
 +
tableextension 50101 "Resco Customer" extends Customer
 +
{
 +
    fields
 +
    {
 +
        field(50000; RowVersionNumber; BigInteger)
 +
        {
 +
            Caption = 'RoW Version Number';
 +
            DataClassification = CustomerContent;
 +
        }
 +
    }
 +
 
 +
    trigger OnAfterModify()
 +
    begin
 +
        Rec.RowVersionNumber := GetRowVersionNumber(Rec);
 +
        Rec.Modify(false);
 +
    end;
 +
 
 +
    procedure GetRowVersionNumber(var recordCustomer: Record Customer) RowVersion: BigInteger
 +
    var
 +
        RecRef: RecordRef;
 +
    begin
 +
        RecRef.GetTable(recordCustomer);
 +
        RecRef.GetBySystemId(recordCustomer.SystemId);
 +
        RowVersion := RecRef.Field(0).Value();
 +
    end;
 +
}
 +
</syntaxhighlight>
 +
 
 +
Second step is to add this custom field to your Page/new Page:
 +
 
 +
Some fields will need some special handling, use triggers: OnModifyRecord(), OnAfterGetCurrRecord(), OnInsertRecord() to create your custom logic (e.g., mapping of status).
 +
 
 +
<syntaxhighlight lang="pascal">
 +
page 50110 "Resco Customer"
 +
{
 +
    //....
 +
    //your page definition
 +
    //....
 +
    layout
 +
    {
 +
        area(Content)
 +
        {
 +
            repeater(Group)
 +
            {
 +
                //......
 +
                //your fields
 +
                //......
 +
 
 +
                field(RowVersionNumber; Rec.RowVersionNumber)
 +
                {
 +
                    ApplicationArea = All;
 +
                    Caption = 'VersionNumber', Locked = true;
 +
                }
 +
            }
 +
        }
 +
    }
 +
}
 +
</syntaxhighlight>
 +
 
 +
Upload the created table and page extensions to your Business Central organization.
 +
# Open Web Services in your Business Central.<br>[[File:Open web services in business central.png|600px]]
 +
# Click '''New'''.<br>[[File:Create a new web service.png|600px]]
 +
# Select Page, Object ID of created Page and define Service Name (it will be displayed in Integration Editor in Woodford) and Save.
 +
 
 +
Return to Resco Cloud.
 +
# Open your integration, enable external entity for integration, and do the mapping.
 +
# Select Local entity, Primary Key, Version Number - RowVersionNumber and proceed with field mapping.
 +
 
 +
== Synchronization ==
 +
 
 +
The first sync is [[full sync]]: all records of enabled local entities are cleaned up on Resco Cloud and all records of external entities are downloaded from Business Central. Every next sync is incremental - only changes are transferred.
 +
 
 +
=== On Demand ===
 +
 
 +
# Double-click the integration in Woodford.
 +
# Click '''Sync''' to start synchronization manually.
 +
 
 +
=== Scheduled ===
 +
# Open Admin Console.
 +
# Select Processes Center > Processes.
 +
# Click New to create a new process.
 +
# Select workflow/job.
 +
# Schedule or define condition when sync should be executed.
 +
# From toolbar click Step > Function > pick Server > IntegrationSync > enter name of your integration.
 +
 
 +
=== Web Service ===
 +
 
 +
Basic authorization
 +
 
 +
<syntaxhighlight lang="http">
 +
https://rescocrm.com/rest/v1/integration/{name of your integration}/$sync
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="xml">
 +
<IntegrationRequest IsSynchronous="false" KeepStatusLog="true">             
 +
    <Ticket></Ticket>
 +
</IntegrationRequest>
 +
</syntaxhighlight>
  
 
== See also ==
 
== See also ==

Latest revision as of 16:07, 1 December 2021

Wikipedia logo
Wikipedia has an article on a similar subject:

Microsoft Dynamics 365 Business Central is an enterprise resource planning system from Microsoft. The product is part of the Microsoft Dynamics family.

Resco Cloud can connect to Business Central using one of the following methods:

  • Via Power Automate + Resco Cloud connector: full-featured integration using a third-party Microsoft service
  • Using Integrations (Preview): connect your Resco Cloud organization to Business Central directly from Woodford.

This article explains the second method in more detail.

Connect to business central directly from resco cloud.png

Register Resco application in Business Central

Before you can start migrating data between Resco Cloud and Business Central, you must register the Resco application (clientId) in Business Central and grant Resco consent with accessing Business Central data.

  1. Log in to your Business Central organization and go to the Azure Active Directory Applications.
    Bc1.png
  2. Click New and fill out the registration form.
    Bc2.png
  3. As Client ID, use 4abedb2f-19bc-402f-b0b5-b8d17e85aa04.
  4. Add User Permission Sets (SUPER).
  5. Grant the necessary consent.
    Bc3.png

Install Resco extension on Business Central

The extension is required (but see below) for synchronizing between Resco Cloud and Business Central.

  1. Download the extension from Resco web.
  2. Log in to Business Central and search for "extensions".
    Install extension 1.png
  3. On the Manage tab, click Upload Extension and upload the zip file.
    Install extension 2.png
  4. Open Web Services, click New, select Page, select RescoCustomer and write RescoCustomer as Service Name.
  5. Repeat it for every custom page from the Resco extension. (RescoCustomer, RescoContact, RescoServiceOrder).

Can I integrate without extension?

Yes, but... it depends on your customization of Business Central.

The integration offers two modes of synchronization:

  • Full sync: download all records of an entity.
  • Incremental sync: download only changed records.

To take advantage of the faster, incremental sync, Business Central must have a Version Number field on the entity; and this field must be defined in the mapping in Woodford.

Version number.png

You can define the version number using the extension. We recommend using row version number (Big Integer) as the Version number field. You can use Date/DateTime fields as well, but it won't be 100% incremental sync.

Create integration

  1. Start Woodford and select Integrations from the Administrator menu.
  2. Click New and enter the following details:
    Bc4.png
    • Name - enter a name of your integration
    • Connector - select OData
    • URL - enter the URL of Business Central OData endpoint (e.g., https://api.businesscentral.dynamics.com/v2.0/b8cc0002-2542-46ed-8584-d4868701fbc4/Production/ODataV4/)
    • Username - BC account's email address
    • Password - BC account's password
    • CustomQueryParamaters - custom query, which should be added to the every request (e.g., &company=CRONUS%20USA%2C%20Inc.). It is important to include the correct &company parameter.
  3. Click Save.

You have created the integration; you can now set it up.

Customize integration

How to change default mapping?

Mapping allows you to match entities and fields on Business Central with entities and fields on Resco. Out of the box, three entities are mapped and ready for synchronization: account, contact, and work order.

  1. Double-click the integration.
  2. Select an entity on the External Entities pane (left).
  3. Select the matching local entity, its primary key, and version number.
  4. In the table below, define the mapping for fields that you want to integrate: select the checkbox and choose a matching Local Field.
  5. For all fields with the local type Lookup, enter the lookup Target in this format: [localEntity].[localField] (e.g., account.integration_bc_pk).
  6. Save all changes.

How to enable/disable entity for synchronization? What if I only want to upload or download?

  1. Double-click the integration.
  2. Select an entity from the External Entities pane.
  3. Click Enable or Disable.
  4. Use Sync Direction to control if you want to exchange data in both direction, upload only, or download only.
  5. Save all changes.

How to change Sync Filter?

If you want to restrict what data to sync, consider setting up a Sync Filter.

  1. Double-click the integration.
  2. Select an entity from the External Entities pane.
  3. Click Download Filter or Upload Filter.
  4. Enter custom conditions that serve as a filter for records.
  5. Save all changes.

Can I sync two external entities with one entity on Resco Cloud?

The schema of the external system can be vastly different from your Resco Cloud organization. Fortunately, you can map two (or more) external entities to a single Resco Cloud entity. Use upload sync filter to ensure that the correct records from Resco Cloud end up in the right entity on the external system.

Multiple entities.png

How to add a new entity to integration?

Synchronization is effective if the versionnumber of entity (table in Business Central) is compared from the last sync. Therefore we recommend creating a table extension to access field(0) - versionnumber in Business Central.

This is an example of an extension for the Customer table. Apply the same principles to other tables.

tableextension 50101 "Resco Customer" extends Customer
{
    fields
    {
        field(50000; RowVersionNumber; BigInteger)
        {
            Caption = 'RoW Version Number';
            DataClassification = CustomerContent;
        }
    }

    trigger OnAfterModify()
    begin
        Rec.RowVersionNumber := GetRowVersionNumber(Rec);
        Rec.Modify(false);
    end;

    procedure GetRowVersionNumber(var recordCustomer: Record Customer) RowVersion: BigInteger
    var
        RecRef: RecordRef;
    begin
        RecRef.GetTable(recordCustomer);
        RecRef.GetBySystemId(recordCustomer.SystemId);
        RowVersion := RecRef.Field(0).Value();
    end;
}

Second step is to add this custom field to your Page/new Page:

Some fields will need some special handling, use triggers: OnModifyRecord(), OnAfterGetCurrRecord(), OnInsertRecord() to create your custom logic (e.g., mapping of status).

page 50110 "Resco Customer"
{
    //....
    //your page definition
    //....
    layout
    {
        area(Content)
        {
            repeater(Group)
            {
                //......
                //your fields
                //......

                field(RowVersionNumber; Rec.RowVersionNumber)
                {
                    ApplicationArea = All;
                    Caption = 'VersionNumber', Locked = true;
                }
            }
        }
    }
}

Upload the created table and page extensions to your Business Central organization.

  1. Open Web Services in your Business Central.
    Open web services in business central.png
  2. Click New.
    Create a new web service.png
  3. Select Page, Object ID of created Page and define Service Name (it will be displayed in Integration Editor in Woodford) and Save.

Return to Resco Cloud.

  1. Open your integration, enable external entity for integration, and do the mapping.
  2. Select Local entity, Primary Key, Version Number - RowVersionNumber and proceed with field mapping.

Synchronization

The first sync is full sync: all records of enabled local entities are cleaned up on Resco Cloud and all records of external entities are downloaded from Business Central. Every next sync is incremental - only changes are transferred.

On Demand

  1. Double-click the integration in Woodford.
  2. Click Sync to start synchronization manually.

Scheduled

  1. Open Admin Console.
  2. Select Processes Center > Processes.
  3. Click New to create a new process.
  4. Select workflow/job.
  5. Schedule or define condition when sync should be executed.
  6. From toolbar click Step > Function > pick Server > IntegrationSync > enter name of your integration.

Web Service

Basic authorization

https://rescocrm.com/rest/v1/integration/{name of your integration}/$sync
<IntegrationRequest IsSynchronous="false" KeepStatusLog="true">              
    <Ticket></Ticket>
</IntegrationRequest>

See also