Business Central, Dataverse, Dynamics 365 Sales, Integration, Synchronize, Testing, Tip & Tricks

Test the Solution Integration of Business Central with Dataverse

This is the Twelfth post in the series. If you want to go to previous post click here.

From the series of steps this post is dedicated to Step-Testing:

As a Eleventh Step we will Verify & Test the Integration between Business Central and Dataverse for Custom table we created in both the environments.

Initial Stage post Deploying the Extension, we access the Pages for first time.

We have below data in Dataverse Prospects table:

In BC when we access to CDS Prospects Page:

In BC when we access to Prospects Page:

First we will Add one Record in Dataverse:

Now if we check CDS Prospects Page:

If you remember on CDS Prospects Page we have written code on OnInit trigger to run codeunit – CRM Integration Management, so when page is opened, the data is synchronized to CDS Prospects Page.

On CDS Prospects Page, we have also added action Create in Business Central, if we choose this action:

The record in Dataverse will get transferred to Prospect Table in Business Central

Now Let us Add one Record in Business Central, from Prospect Page.

Business logic for calculating Forcast Revenue is not written in BC, but we have in Dataverse table.

When we synchronize data from BC to Dataverse, that will get calculated automatically.

Select the record we just added in BC. Action-> Dataverse-> Coupling-> Setup Coupling

On the new page that opens, Select Create New, And click OK.

Since we have selected Synchronize After Coupling and direction BC to Dataverse, the record will get transferred to Dataverse Table.

Also you can see the other fields too got calculated. Now if we Synchronize back to BC these fields will get updated in BC.

You can see the Synchronization is happening in both directions.

You can make necessary changes to code in sample walkthrough to achieve your desired results.

Hope you enjoyed learning this trick, and will use in your projects, the skill learned from this series of posts.

I will come up with more similar stuffs. Till then keep exploring, learning and sharing with others.

Take care of yourself and your loved ones. Put your mask, maintain safe distance and don’t forget to get vaccinated.

Advertisement
Business Central, Business Central Dataverse Integration, Business Central Integration Business Central to Common Data Service, Dataverse, Dynamics 365 Sales, Integration, Organization, Permission, Power Apps, Roles, Security, Synchronize

Check & Assign Permissions in Power Apps Environment

This is the Eleventh post in the series. If you want to go to previous post click here.

From the series of steps this post is dedicated to Step-10:

As a Tenth Step we will Verify & Assign Permissions in Power Apps Environment.

This is the final Step, and we will be done with the goal we set in our first post of this series.

Open your Dynamics 365 Sales Environment and Go To Settings.

Under Users + permissions -> Application users.

On next screen Verify “Business Central Integration Business Central to Common Data Service” is selected. If not then select it from “Edit Security Roles”.

From Settings -> Users + permissions -> Security roles

From Security roles select the Business Central Dataverse Integration Then Edit

Select Custom Entities tab and find your table Prospects. Select each circle 4 times to assign Organization, circle should turn completely filled green color.

Select Save and Close.

Now you All done with the steps, Ready to test the solution.

In next post we will test the solution, we created in past 10 posts.

Now you are good to proceed with Next Step.

You can jump to Next Step from here.

Business Central, Dataverse, Dataverse Connection Setup, Dynamics 365 Connection Setup, Fields, Integration, Mappings, Setup, Synchronize

Updating the default Mappings

This is the Tenth post in the series. If you want to go to previous post click here.

From the series of steps this post is dedicated to Step-9:

As a Nineth Step we will Update the default Mappings.

Open the Dataverse Connection Setup using TellMe.

From Actions -> Use Default Synchronization Setup.

Respond Yes to the Confirmation Message.

You will get the confirmation as completed, say OK to continue.

Next open the Microsoft Dynamics 365 Connection Setup from TellMe.

Go To Mapping -> Integration Mappings.

Now you can find your Custom table Prospects.

Go To Fields, you will see Field Mappings for you table as defined in Integration Codeunit in previous step.

Now you are good to proceed with Next Step.

You can jump to Next Step from here.

Action, AL, Business Central, Coupling, Dataverse, Dynamics 365 Sales, Extension, Integration, Page, Procedure, Synchronize, Triggers, Varables, VS Code

Create Actions on the Page for managing Coupling and Synchronization

This is the Eighth post in the series. If you want to go to previous post click here.

From the series of steps this post is dedicated to Step-7:

As a Seventh Step we will Create Actions on the Page for managing Coupling and Synchronization created in previous post.

On page 50120 Prospects created in previous post

Add Variables:

var
   CRMIntegrationManagement: Codeunit "CRM Integration Management";
   CRMCouplingManagement: Codeunit "CRM Coupling Management";
   CDSIntegrationEnabled: Boolean;
   CDSIsCoupledToRecord: Boolean;

Add Triggers:

trigger OnOpenPage()
begin
    CDSIntegrationEnabled := CRMIntegrationManagement.IsCDSIntegrationEnabled();
end;

trigger OnAfterGetCurrRecord()
begin
    if CDSIntegrationEnabled then
        CDSIsCoupledToRecord := CRMCouplingManagement.IsRecordCoupledToCRM(Rec.RecordId);
end;

Add Actions:

    Actions
    {
        area(Processing)
        {
            group(ActionGroupCDS)
            {
                Caption = 'Dataverse';
                Visible = CDSIntegrationEnabled;

                action(CDSGotoProspect)
                {
                    Caption = 'Prospect';
                    Image = CoupledCustomer;
                    ToolTip = 'Open the coupled Dataverse Prospect.';
                    ApplicationArea = All;

                    trigger OnAction()
                    var
                        CRMIntegrationManagement: Codeunit "CRM Integration Management";
                    begin
                        CRMIntegrationManagement.ShowCRMEntityFromRecordID(Rec.RecordId);
                    end;
                }
                action(CDSSynchronizeNow)
                {
                    Caption = 'Synchronize';
                    ApplicationArea = All;
                    Visible = true;
                    Image = Refresh;
                    Enabled = CDSIsCoupledToRecord;
                    ToolTip = 'Send or get updated data to or from Microsoft Dataverse.';

                    trigger OnAction()
                    var
                        CRMIntegrationManagement: Codeunit "CRM Integration Management";
                    begin
                        CRMIntegrationManagement.UpdateOneNow(Rec.RecordId);
                    end;
                }
                action(ShowLog)
                {
                    Caption = 'Synchronization Log';
                    ApplicationArea = All;
                    Visible = true;
                    Image = Log;
                    ToolTip = 'View integration synchronization jobs for the Prospect table.';

                    trigger OnAction()
                    var
                        CRMIntegrationManagement: Codeunit "CRM Integration Management";
                    begin
                        CRMIntegrationManagement.ShowLog(Rec.RecordId);
                    end;
                }
                group(Coupling)
                {
                    Caption = 'Coupling';
                    Image = LinkAccount;
                    ToolTip = 'Create, change, or delete a coupling between the Business Central record and a Microsoft Dataverse row.';

                    action(ManageCDSCoupling)
                    {
                        Caption = 'Set Up Coupling';
                        ApplicationArea = All;
                        Visible = true;
                        Image = LinkAccount;
                        ToolTip = 'Create or modify the coupling to a Microsoft Dataverse Prospect.';

                        trigger OnAction()
                        var
                            CRMIntegrationManagement: Codeunit "CRM Integration Management";
                        begin
                            CRMIntegrationManagement.DefineCoupling(Rec.RecordId);
                        end;
                    }
                    action(DeleteCDSCoupling)
                    {
                        Caption = 'Delete Coupling';
                        ApplicationArea = All;
                        Visible = true;
                        Image = UnLinkAccount;
                        Enabled = CDSIsCoupledToRecord;
                        ToolTip = 'Delete the coupling to a Microsoft Dataverse Prospect.';

                        trigger OnAction()
                        var
                            CRMCouplingManagement: Codeunit "CRM Coupling Management";
                        begin
                            CRMCouplingManagement.RemoveCoupling(Rec.RecordId);
                        end;
                    }
                }
            }
        }
    }

On page 50122 “CDS Prospect List” created above

Add Variables:

var
    CurrentlyCoupledCDSProspect: Record "CDS cr95d_Prospects";

Add Trigger:

trigger OnInit()
begin
    Codeunit.Run(Codeunit::"CRM Integration Management");
end;

Add Procedure:

procedure SetCurrentlyCoupledCDSProspect(CDSProspect: Record "CDS cr95d_Prospects")
begin
    CurrentlyCoupledCDSProspect := CDSProspect;
end;

Add Action:

Actions
    {
        area(processing)
        {
            action(CreateFromCDS)
            {
                ApplicationArea = All;
                Caption = 'Create in Business Central';
                Promoted = true;
                PromotedCategory = Process;
                ToolTip = 'Generate the table from the coupled Microsoft Dataverse Prospect.';

                trigger OnAction()
                var
                    CDSProspect: Record "CDS cr95d_Prospects";
                    CRMIntegrationManagement: Codeunit "CRM Integration Management";
                begin
                    CurrPage.SetSelectionFilter(CDSProspect);
                    CRMIntegrationManagement.CreateNewRecordsFromCRM(CDSProspect);
                end;
            }
        }
    }

Now you are good to proceed with Next Step.

You can jump to Next Step from here.

Business Central, Dataverse, Power Apps, Synchronize, Table

Create Custom table in Dataverse/ Power Apps

This is the Fifth post in the series. If you want to go to previous post click here.

From the series of steps this post is dedicated to Step-4:

As a fourth Step we will Create New Table(s) in Dataverse, below is the structure of the table.

This table will be used to Sync Data between Business Central and Dataverse.

Define all required columns. Same as we have done in Business Central, in previous post.

Next we will define Business Rule, This will make Probability field as mandatory.

See the properties of each component.

Sample data for the table.

If you are not comfortable with creating table in Power Apps environment, I will add one post step wise step how this table was created and data was uploaded in this table. Once this series is completed, will provide link to that post here.

Now you are good to proceed with Next Step.

You can jump to Next Step from here.

Business Central, CDS, Common Data Services, Dataverse, Dynamics 365 Sales, Integration, Ownership, Permissions, Synchronize, Tip & Tricks, URL

Setup a connection to Dataverse

Integration with Business Central is done through Dataverse, and you will find lots of standard settings and tables that are provided by the integration.

This is the Second post in the series. If you want to go to previous post click here.

From the series of steps this post is dedicated to Step-1:

Create connection to integrate and synchronize data with another Dynamics 365 business app, such as Dynamics 365 Sales.

As a first Step we will setup a connection to Dataverse.

Before you start make sure you have below information ready with you:

  • URL for the Dataverse environment that you want to connect to
  • The user’s name and password of an account that has administrator permissions in Business Central and Dataverse.
  • The local currency for the company in Business Central must be the same as the base transaction currency in Dataverse. 

From Assisted Setup under Connect with other systems group choose Set up a connection to Dataverse, as shown below.

This will start the Setup wizard, just follow and provide your information asked on each page.

Click Next to Start configuring Dataverse & Business Central connection.

Here you can select your Dataverse Environment or can enter manually, above screen shows where you can find this url from.

Sign in with an administrator user account and give consent to the application that will be used to connect to Dataverse.


Choose Sign in with administrator user.

After Sign in with administrator user turns green and bold, choose Next.

Select Ownership and Click Next.

Click on Finish to complete the Setup.

Next open the Dataverse Connection Setup from TellMe.

Select from Connection -> Test Connection

You can check Microsoft docs for more information

Connect to Microsoft Dataverse

If all are OK it should show the Connection test Successful message.

Now you are good to proceed with Next Step.

You can jump to Next Step from here.

AL Table Proxy Generator Tool, Assisted Setup, Business Central, CDS, Common Data Services, Coupling, Custom Tables, Dataverse, Deploy, Dynamics 365 Sales, Integration, Mappings, Package, Permissions, Power Apps, Scheduling, Synchronize, Testing

Integration in Business Central with Dataverse/ Common Data Services/ Dynamics 365 Sales/ Power Apps

In this post I will discuss about how we can Synchronize data to Custom Tables using Dataverse.

This post is divided in series of small posts, one post for each involved step.

You follow each post link in sequence and at end we will achieve the final Goal set in starting of this post. 

This post will walkthrough setting up an integration between a Custom table Prospects in Business Central and a Custom table Prospects in Microsoft Dataverse.

One thing important keep in mind while doing all the steps we need to use the Admin login you used to setup these environments.

Also, the Base Currency of Business Central & Dataverse Environment should be same else you will run into issue.

If the currencies of Business Central and Dataverse do not match, similar message will be displayed.

LCY Code XXX does not match ISO Currency Code XXX of the Dataverse base currency.

The Base Currency defined for Dataverse after setup is not possible to change however you can match it in Business Central by changing LCY Code in General Ledger Setup.

Let’s start with introduction to environment we are going to use, throughout the process and steps described below.

Introduction to Environment:

Before we start with the Steps Involved, let me introduce with the environment which I am going to use in this walkthrough. 

Business Central Environment:

Dynamics 365 Sale Environment:

Setup required to Connect with external system:

You can find below options in Business Central Assisted Setup.

The following are the Steps we will follow:

Follow each step above in same sequence.

For more detailed insight refer to below Microsoft Documents:

Customizing an Integration with Microsoft Dataverse

AL Table Proxy Generator

Scheduling a Synchronization between Business Central and Dataverse

Hope you enjoyed the learning by example. Wait for next post, will be back soon.

See you in next post soon with similar kind of stuffs.

Till then keep Exploring, learning and sharing with others.