Dual Write_005 - Create a custom entity in F&O and then use it with Dual-write to sync data to Dataverse
Dual Write_005 - Create a custom entity in F&O and then use it with Dual-write to sync data to Dataverse
1
1. Overview ....................................................................................................................................................................... 3
2. Lab Prerequisites ........................................................................................................................................................... 3
3. Create a Custom Table, Form and Data entity in Visual studio .................................................................................... 3
3.1 Create a custom model. .......................................................................................................................................... 3
3.2 Create Extended Data Types ................................................................................................................................... 7
3.3 Create a table ........................................................................................................................................................ 12
3.4 Create a form ........................................................................................................................................................ 17
3.5 Create Staging Table /Data Entity ......................................................................................................................... 22
3.6 Create a Display menu item .................................................................................................................................. 25
3.7 Create an extension of CommonMenu ................................................................................................................. 26
3.8 Full Build and DB Syncronize the Model ............................................................................................................... 28
Step 3.9 Fill Data in the Book Table form ................................................................................................................... 30
4.0 Create custom Entity in CE ........................................................................................................................................ 31
4.1 Create a custom table in Dataverse ................................................................................................................ 31
4.2 Create Table Columns ........................................................................................................................................... 34
4.3 Create a custom table map for Book table entity ................................................................................................. 36
4.4 Run Initial Sync on Book table entity map ............................................................................................................ 38
4.5 Test Live Sync for Book table entity map: F&O -> Dataverse ............................................................................... 39
4.6 Test Live Sync for Book table entity map: Dataverse -> F&O ............................................................................... 41
2
1. Overview
The scope of this lab is to provide step-by step instructions that help to get familiar with how create a custom entity
in D365FO and consume it in Dual Write. It assumes the user has basic familiarity with AOT and creating D365FO
objects in visual studio.
2. Lab Prerequisites
- A dev/test environment deployed from LCS creating a Dynamics 365 Finance and Operations Cloud hosted
environment (CHE) with Power Platform using your own Test/Microsoft 365developer tenant admin account.
https://supportability.visualstudio.com/DynamicsFO/_wiki/wikis/Dynamics%20FO/767304/Labs
https://supportability.visualstudio.com/DynamicsFO/_wiki/wikis/Dynamics%20FO/656962/Build-your-own-Cloud-
Hosted-Environment-(CHE)-with-Power-Platform-for-testing-and-development
- Dual-write should be setup with at least one legal entity like USMF
(b) Open Visual Studio 2019 and above as Administrator (whenever you launch Visual studio use the Administrator
mode)
(c) Create a custom model from Dynamics 365 > Model management > Create Model:
3
(d) Enter the details below or any other naming details you wish and press Next
(e) Select Create new package radio button and then click Next
4
(f) Select the below checked marked referenced packages and click Next
(g) In Summary page, keep the default settings and click Next
5
(h) Edit the following Project name and Solution name and click “Create”
6
3.2 Create Extended Data Types
Size: 10
(ii) Right click on the project name DWExtensionProject, in the Solution Explorer and
click on Add > EDT > String
Name: BookTitle
Set properties:
Size: 30
7
(b) Right click on the project name DWExtensionProject, in Solution Explorer and click on Add > EDT >
Integer
Name: AvailableNumber
Set property:
Label: Available number
8
(c)
(i) Right click on the project name ‘DWExtensionProject’, in Solution Explorer and click on Add > EDT >
Enum > select Base Enum template
Name: BookGenre
Set properties - Label: Book genre
(ii) Create and add following 4 Element Values by right clicking BookGenre, in middle pane, and select New Element:
9
(d) Right click on the project name DWExtensionProject, in Solution Explorer and click on Add > EDT >
Enum
Create an EDT Of type Enum based on the above BaseEnum. Set the following properties:
Name: BookGenreEDT
EnumType: GookGenre
(e) Right click on the project name ‘DWExtensionProject’, in Solution Explorer and click on Add > EDT >
Date > select EDT Date template
Name: AvailableDate
10
- click Save all in Visual studio
11
3.3 Create a table
(a) Right click on the project name ‘DWExtensionProject’, in Solution Explorer, and click on Add > Table…
Name: BookTable
Set properties - Label: Book table
(b) Add all created Extended Data types in previous step as table fields:
Select all the fields from the solution explorer and drop it on the Fields node in the middle pane
12
(ii) Drag and drop all the five fields on the BookTableFieldGroup
13
(d) Create two table indexes
(i) Unique Index name: “BookIdIdx”
- Right click on Indexes node and select create a new index.
- Drag and drop the BookId field from under the Fields section on the new index.
14
(ii) Non-unique index name: BookTitleIdx
- Right click on Indexes and create a new index.
- Drag and drop the BookTitle field from under Fields section on to the new index.
15
(e) Select the BookTable in middle pane and in the properties section
Set “Title field1”= BookId
Set “Title field2”= BookTitle
16
3.4 Create a form
(a) Right click on the project name DWExtensionProject, in Solution Explorer, and click on Add > Form…
Name: BookTableForm
17
(c) Create a Custom Design pattern
(i) In the middle pane, right click on Design | Pattern: <unspecified>
18
(iii) Right click on Design|Pattern: Custom and select New > QuickFilter
(iv) Right click on Design|Pattern: Custom and select New > Grid
19
- Set below highlighted properties values for the Grid
- Drag and drop the BookTableFieldGroup on to the right side on top of FormGridControl(Grid)
- This will create a BookTableFieldGroup (Group). Verify the properties of this new group looks the same
as below:
20
(iv) Notice the group also shows all the fields. Click on Save all button in Visual studio menu, to save your progress
21
3.5 Create Staging Table /Data Entity
(a) Find BookTable table in the project, then right click and select Open
(b) Right click on the name BookTable > Select Add-Ins > Create data entity
(c) Wait for process to complete. The following objects will be created in your data project
22
23
(e) Right click on BookTableEntity and select Open
Set/Verify the following property values:
24
3.6 Create a Display menu item
Create a Display menu Item so that we can view the form in D365FO
(a) Right click on the project name ‘DWExtensionProject’, in Solution Explorer, and click on Add > New
Item…
(i) In the Add New Item form, from Left hand side under Dynamics 365 Items select User Interface
(ii) In the middle pane select Display Menu Item
(iii) Fill Name: BookTableMenuItem
(iv) Click on Add
(v) Once the BookTableMenUItem is created, select it in the middle pane, and then fill in the
Properties on bottom-left as follows:
25
3.7 Create an extension of CommonMenu
(a) In the Application Explorer search for CommonMenu
(b) Right click on CommonMenu shown under the AOT and click on Create extension..
Notice in the Solution Explorer it has created a new object CommonMenu.DWExtensionModel
26
(d) Click on Save all in the Visual studio menu
27
3.8 Full Build and DB Syncronize the Model
(i) From the Visual Studio Menu, go to menu Extensions > Dynamics 365 and select Build models…
(ii) Under the Packages tab, search and find DWExtensionModel, and select the check box next to it.
28
(iii) Select the Options tab, make the following selections underneath it and then press Build button.
(iv) The build will take a while. Ensure you get no errors. Ignore all the warnings.
29
Step 3.9 Fill Data in the Book Table form
(i) Log in to Dynamics 365 FO. Go to Modules > Common > Common. Verify that it has created the Book
table form menu item:
(ii) Click on it to open the form. Click on Edit in the menu and then create a couple of records as shown
below, and click on Save just to ensure the form is functional.
30
4.0 Create custom Entity in CE
First we will create a custom table in Dataverse that has similar fields as BookTable that we can copy the
data to.
(i) Log on to https://make.powerapps.com
Make sure to select the right environment you are using example:
(iii) Click on +New table. A side form titled New form opens. Under the Properties tab enter the
following values:
31
(iv) Next click on Primary column and enter the below details:
32
(v) Click on Advanced options, and review the below default options without making any changes:
33
4.2 Create Table Columns
(ii) Create 6 new Columns as below. Save each column before creating the next column.
1 2 3 4 5
34
(iii) Create a final new Column for Company as below and click Save
(v) Click on Advanced > Publish table. Wait till you see
35
4.3 Create a custom table map for Book table entity
(i) Log back into D365FO
(ii) Go to Data Management workspace > Dual write
(iii) Click on Add table map
(iv) A side form opens with title Add table. Fill in the below fields:
- Click on Save
(v) For the new created table mapping, add following 5 bi-directional fields
36
Please note: The DATAVERSE fields prefix on your system may have a different value then what you see.
The fields on my system start with 'cr944_'
(vi) Click on root Dual-write and then click on Integration key menu
37
4.4 Run Initial Sync on Book table entity map
38
4.5 Test Live Sync for Book table entity map: F&O -> Dataverse
(i) Log on to FnO, from the UI front end, find the form menu under the following sub-menu:
(ii) Open the form on the legal entity that is setup to sync with DATAVERSE
- E.g on my DATAVERSE I am only syncing records from company USMF
- Hence I switched to USMF company and then opened the form
- - and then create a record as shown below (Only for testing purposes)
39
(iii) Log on to https://make.powerapps.com
- Connect to the correct Environment.
- Then go to Dataverse > Tables > FOBookTable
- Then verify the record got created:
40
4.6 Test Live Sync for Book table entity map: Dataverse -> F&O
(ii) On the FoBookTable, click on Edit button and then select Edit
41
(vi) You will see the new record you created on the FOBookTable
If you got this far then congratulate yourselves! This completes the sample document with code samples to
demonstrate creating a custom entity and using it with Dual-write to sync data.
This document was edited whilst following the steps. If you find any errors please report them to:
MansourM and AnupShah
42
---------------------------------------
Disclaimer:
This sample document and sample code examples is for illustration purposes only. Microsoft disclaims all warranties
and conditions with regards to use of the sample document and sample code for other purposes. Microsoft shall not,
at any time, be liable for any special, direct, indirect, or consequential damages, whether in an action of contract,
negligence or other action arising out of or in connection with the use or performance of the document and sample
code examples. Nothing herein should be construed as constituting any kind of warranty.
-----------------------------------
43