Hi, Readers.
Today I would like to talk about an interesting question I was asked recently, can we timely synchronize Dataverse entity changes without Power Automate?
Business apps often use data from more than one source. Dataverse combines data into a single set of logic that makes it easier to connect Business Central to other Dynamics 365 applications. For example, Dynamics 365 Sales or your own application built on Dataverse. To learn more about Dataverse, go to What is Dataverse?
We have discussed the following topics.
- Dynamics 365 Sales and Business Central integration setup (Set up a connection to Dataverse and Set up a connection to Dynamics 365 Sales)
- Dynamics 365 Business Central: Customizing an Integration with Microsoft Dataverse (Integrate custom tables)
- Business Central 2024 wave 1 (BC24): Changes to AL Table Proxy Generator tool (altpgen) – Two additional arguments: ClientId and RedirectUri
You can synchronize Business Central with Dataverse on scheduled intervals by setting up jobs in the job queue. Default synchronization job queue entries: Default Synchronization Frequency is 30 mins
Job Queue Entry | Description | Direction | Integration Table Mapping | Default Synchronization Frequency (mins) | Default inactivity sleep time (mins) |
---|---|---|---|---|---|
CONTACT – Common Data Service synchronization job | Synchronizes Dataverse contacts with Business Central contacts. | Bidirectional | CONTACT | 30 | 720 (12 hours) |
CURRENCY – Common Data Service synchronization job | Synchronizes Dataverse transaction currencies with Business Central currencies. | From Business Central to Dataverse | CURRENCY | 30 | 720 (12 hrs) |
CUSTOMER – Common Data Service synchronization job | Synchronizes Dataverse accounts with Business Central customers. | Bidirectional | CUSTOMER | 30 | 720 (12 hrs) |
VENDOR – Common Data Service synchronization job | Synchronizes Dataverse accounts with Business Central customers. | Bidirectional | VENDOR | 30 | 720 (12 hrs) |
SALESPEOPLE – Common Data Service synchronization job | Synchronizes Business Central salespeople with Dataverse users. | From Dataverse to Business Central | SALESPEOPLE | 30 | 1440 (24 hrs) |

So please note that this is not real-time. If you need to achieve real-time, Microsoft learn (docs) mentions that this requires Power Automate. More details: Use a Power Automate flow to timely synchronize Dataverse entity changes

This is the standard solution. But is there a way if the user does not have a Power Automate license or does not want to create a Power Automate flow? In conclusion, there is no way to achieve this for standard tables and standard integration, but for new custom tables, real-time synchronization can be achieved by directly using integration table (CDS TableType). More details: TableType Property
CDS | runtime version 5.0 | Specifies the table as an integration table for integrating Dynamics 365 Business Central with Dynamics 365 Apps. |
Let’s look at a simple example.
First we need to complete the Dataverse Connection Setup, More details: Dynamics 365 Sales and Business Central integration setup (Set up a connection to Dataverse and Set up a connection to Dynamics 365 Sales)


Dataverse Connection Setup:

Then we customize an new integration between Business Central and Microsoft Dataverse according to the process mentioned in Dynamics 365 Business Central: Customizing an Integration with Microsoft Dataverse (Integrate custom tables). But this time we only need to do the first three steps and the last step.

1. Create a new table and page in Business Central



PS: To test whether options are supported, I created an Enum.

2. Create a new table in Dataverse.
App Launcher -> Power Apps -> Tables:


Choose Create new tables

Now there is a very convenient feature in Dataverse. Create a table from Excel file.

This Excel file can be obtained using Open in Excel in BC.


Very smart.

You can click Properties to modify some properties of the table. If there is no problem, click Save and exit in the upper right corner to quickly create this table.


Done.
Name: cra00_bookrecord


3. Using AL Table Proxy Generator tool to create integration table.
App registration:



Then in Windows PowerShell:
cd "C:\Users\yzhu\.vscode\extensions\ms-dynamics-smb.al-15.0.1275389\bin\win32\altpgen"

.\altpgen -project:"C:\Users\yzhu\Documents\AL\New integration with Dataverse" -packagecachepath:"C:\Users\yzhu\Documents\AL\DataverseTest\.alpackages" -serviceuri:"https://orge9084970.crm.dynamics.com" -entities:cra00_bookrecord -baseid:50200 -tabletype:CDS -clientid:61b08a00-14bb-40e7-bac8-def3bc9349a4 -redirecturi:"http://localhost"

Done.

TableType = CDS

Primary key:

We can then create a list page to display the values of this table.
All fields: These fields come from Dataverse, and you can add only the fields you need.

But at this point, we still need the most important step, adding permissions in Power Platform Admin Center. Otherwise, the following error will be displayed when you open the page.
Principal user (Id=83ab449c-9db6-ef11-b8e8-7c1e520112d5, type=8, roleCount=2, privilegeCount=122, accessMode=’4 Non-interactive’, AADObjectId=’fb972588-7279-446f-ac3d-dda75d4bce21′, MetadataCachePrivilegesCount=5093, businessUnitId=8231e407-b0b4-ef11-b8e8-6045bdfe1e3b, ApplicationId/FullName: 88c57617-94ff-4043-a396-8a85a8d38922/Business Central Integration Business Central to Common Data Service), is missing prvReadcra00_bookrecord privilege (Id=f507b674-3cfd-40fa-99ac-520db4b8c6aa) on OTC=10570 for entity ‘cra00_bookrecord’ (LocalizedName=’Book Record’). context.Caller=83ab449c-9db6-ef11-b8e8-7c1e520112d5. Consider adding missed privilege to one of the principal (user/team) roles.

You can open Power Platform Admin Center from Power Apps.

Then in the Power Platform admin center, select the environment and choose Settings.


Then go to User + permissions -> Security roles.

Click Business Central Dataverse Integration

Find your custom entities and add permissions

Choose Save.

That’s all. Then we can open the page where the CDS TableType table is SourceTable.

Then we can forget about the table we created, in my case it is table 50200 “Lab Book”. Just use this CDS table directly, why? Because it is synchronized in real time.
Test video:
PS: If the following error occurs when opening the list page, please add the new table mapping manually, which is much easier than adding it in Codeunit.
Table connection for table type CRM must be registered using RegisterTableConnection or cmdlet New-NAVTableConnection before it can be used.
More details: Business Central 2024 wave 1 (BC24): Add table and field mappings to existing integration tables (Dataverse)



Select Sync Only Coupled Records to synchronize only the coupled records, but since there are no coupled records, they will not be synchronized.


Done. Then the page can be opened.

If this error still occurs the next time you open the page, adding the following code to the OnInit (Page) trigger of the page can solve the problem.

So in this way, we do not need to create an integration codeunit and add actions on the page for managing coupling and synchronization. We also do not need to set up a Job Queue. Simply put, we only customize half of the standard integration. Just do this part:

I simply tested that this new table can be inserted, modified and deleted through AL, and of course it will be automatically synchronized. For example:


Test video:
What’s the downside to this approach? We’re using a completely new table, not the one we created at the beginning. So this is why the standard table can’t do it.
Great. This may not be a recommended approach. Give it a try!!!😁
Added two tests: users who only update data in Dataverse do not need a BC license, and vice versa, users who update data in BC do not need a Dataverse license.
PS:
1. If you only synchronize custom tables, you can delete other standard mapping tables.

4. Review of Business Central & Dataverse integration
END
Hope this will help.
Thanks for reading.
ZHU
コメント