Tuesday, 24 October 2023

Data Entities in D365 FnO

 

Data management - Data entities

·       Data entity is a conceptual abstraction and encapsulation of one of more underlying tables.

·       Data entity represents a common data concept or functionality, for example, Customers or Vendors.

·       Data entities are intended to be easily understood by users familiar with business concepts. After data entities are created, you can reuse them through the Excel Add-in, use them to define import/export packages, or use them for integrations

A data entity represents a meaningful set of data. For instance, a data entity could be created for a customer that contains information from various database tables that define what a customer is, e.g., name, payment information, addresses, etc. A data entity organizes all this data in a way that’s convenient to handle and allows users to work with the entity itself to import or export data, rather than having to import or export individual tables.

 

Create a Data Entity in D365

Let’s create a data entity to handle exporting and importing item serial numbers using single database InventSerial.

 

·       Create a D365 project in Visual Studio named DataEntityExample. To create a new entity, right-click the project and then click Add > New item. The Add New Item dialogue box opens.

·       Select Data Entity, and then set the Name property to ItemSerialNumber. Then click the Add button.

 

Create a Data Entity in D365

 

In the Data Entity Wizard, all of the properties will be defaulted except Primary datasource. Select InventSerialtable as the primary datasource to export/import the item serial numbers. Click the Next button.

 

Create a Data Entity in D365 2

Add fields to the new entity from the data source InventSerial as shown in the following screenshot. Click the Convert labels to field names checkbox to generate names from the existing labels.

Create a Data Entity in D365

Click Finish. The newly created data entity and staging table are added to the project.

 

Create a Data Entity in D365

In Solution Explorer, right-click on the ItemSerialNumber data entity node and then click Open. Set the Labelproperty to Item Serial Numbers. This is the name that will get displayed in the data entity list.

To make the entity available in data management, the property Data Management Enabled should be set to Yesand the property Data Management Staging Table should be ItemSerialNumberStaging.

To make the entity available in an Odata scenario, the Public Collection Name and Public Entity Name will get defaulted, and the property Is Public should be set to Yes.

Create a Data Entity in D365

 

Now open the ItemSerialNumberStaging table in the designer. Staging tables are used in import/export scenarios to temporarily store the data being exported and imported. In many cases, staging tables are mapped 1:1 to an entity.



Note that the first four fields (DefinitionGroup, ExecutionId, IsSelected and TransferStatus) are the standard fields of a data entity staging table. The table also contains the data fields we selected while creating the data entity. Note that the data entity relations will be created automatically.

Create a Data Entity in D365

In Solution Explorer, right-click the project, and then click Properties. Set Synchronize database on build property to True.

Note:  Entities are created as views in Microsoft SQL Server, and staging tables also are added. Therefore, we must sync a database when we build entities.

 

Data Entities in D365 FnO

  Data management - Data entities ·        Data entity is a conceptual abstraction and encapsulation of one of more underlying tables. ...