Work with composite data entities

Completed

A composite entity is a concept that allows you to build a single entity by using multiple entities that are related to each other. Usually, you'd use the concept in scenarios where you can represent an entity as a single document, such as a sales order header, sales order line, invoice header, invoice line, and vendor catalog.

A composite entity is applicable in asynchronous integration scenarios rather than synchronous OData scenarios. A programmatic interface isn't available for composite entities in X++, and it's only supported for a data management platform that's part of XML file-based imports and/or exports.

Importing and exporting composite entities is a quick and simple process within the Data management workspace in finance and operations apps.

To import or export a composite data entity, follow these steps:

  1. Select the Import/Export tile in the Data management workspace.
  2. Enter a name in the Name field.
  3. Select the data source format for imports or add the entity to export.
  4. Select Import for imports or select Download package to perform an export.

Work with aggregate data entities

An aggregate data entity is conceptually different from data entities, which are used for import and export with the data management framework. Aggregate data entities are based on views of data, and you can use them to consolidate, summarize, and simplify the data structure for analytics purposes.

Aggregate data entities have the following components:

  • Aggregate measurements
  • Aggregate dimensions
  • Model dimension references

When you build the aggregate data entity with the IsPublic property set to true, you can access it with OData as data entities by using the same url: https://your dynamics name.dynamics.com/data/aggregate data entity.

To create aggregate data entities, all development happens in Visual Studio.

To create an aggregate measurement in Visual Studio, follow these steps.

  1. In Solution Explorer, right-click your project or activate the context menu, and then select Add > New item.
  2. Select Analytic and Aggregate measurement.
  3. Enter a name for the aggregate measurement, and then select Add.
  4. In Application Explorer, go to Data model > Views.
  5. Select CustInvoiceTransExpanded, and then drag it to the MeasureGroup1 on the aggregate measurement.
  6. Go to the dimension node and remove the Date field.
  7. Go to the measures node and create a new measure.
  8. Select the LineAmountMST field and then select Sum as Default Aggregate in the properties.
  9. Select Save all.

To create aggregate dimensions, follow these steps.

  1. In Solution Explorer, right-click your project or activate the context menu, and then select Add > New item.
  2. Select Analytic and Aggregate dimension.
  3. Enter a name for the aggregate dimension, and then select Add.
  4. In Application Explorer, go to Data model > Views.
  5. Select CustInvoiceTransExpanded, and then drag it to the root of the aggregate dimension.
  6. Go to the attributes node and remove all items except ItemId and MyAggregate dimension.
  7. Select Save all.

To model dimension references, follow these steps.

  1. In Solution Explorer, select the aggregate dimension and then drag it into the dimensions node on the aggregate measurement. A new out dimension node is created on the aggregate measurement.
  2. Right-click the new node, or activate the context menu, and then select New relation.
  3. In the properties, select ItemId as the field and ItemId as the related field.
  4. Select Save.

To deploy the aggregate measurement, follow these steps.

  1. Select the properties for the top node on the aggregate measurement and then verify that Usage is set to InMemoryRealTime.
  2. In Solution Explorer, right-click the aggregate measurement or activate the context menu, and then select Add Column Store Indices.
  3. Select Save all, and the measurement indexes are created in the project.

To create an aggregate data entity, follow these steps.

  1. In Solution Explorer, right-click your project or activate the context menu and then select Add > New item.
  2. Select Analytic and Aggregate Data Entity.
  3. Enter a name for the aggregate data entity and then select Add.
  4. In Solution Explorer, go to Aggregate measurement and then drag it into the data source node on the new aggregate data entity.
  5. Go to Data source > Aggregated measurement > Measures and then drag LineAmountMST to the field’s node.
  6. Set up the measurement property and the extended data type property as applicable.
  7. Go to Data source > our aggregated measurement and dimensions and then drag the new aggregated dimension to the field’s node. Set the Name property and then select the field in the Attribute property.
  8. Set the IsPublic top node property to Yes to enable the aggregate data entity for OData and then enter names for the public collection name and public entity name as applicable.
  9. Create a primary key for the ItemId field.
  10. Set the primary key on the top node to the key name.
  11. Select Save all and then build.

Now, you can test the aggregate data entity by using the https://your solution name.axcloud.dynamics.com/data/Aggregate Data Entity Collection name URL.

The following code sample illustrates how the output might appear.

{
  "@odata.context":"https://mb-500-dev23bd5795219c31f9devaos.axcloud.dynamics.com/data/$metadata#MyAggregateDataEntityCollection","value":[
    {
      "@odata.etag":"W/\"JzAsMTAxMCc=\"","ItemId":"","LineAmountMST":5636950
    },{
      "@odata.etag":"W/\"JzAsMTAxMCc=\"","ItemId":"D0001","LineAmountMST":3236760
    },{
      "@odata.etag":"W/\"JzAsMTAxMCc=\"","ItemId":"D0003","LineAmountMST":1651826
    },{
      "@odata.etag":"W/\"JzAsMTAxMCc=\"","ItemId":"D0004","LineAmountMST":11798000
    }
  ]
}