Extending standard data entity with fields coming from a view
Published On: December 19, 2018Categories: Technical
When working with Microsoft Dynamics AX, we often encounter with situations where a standard table needs to be extended with more fields that come from a view, when the relation to the view is through RecId.
When using the table for data export and import the data management framework can not find the related record coming from the view, so this needs to be set manually in the findEntityDataSource method of the entity, which is used for the import export. Because the scenario involves a standard table and a standard entity, we need to use an extensible solution and in addition of extending data entity we need to add an event handler method that is subscribed onFoundEntityDataSource event.
We all know that in our Microsoft Dynamics community we have a lot of challenges with extending the Data management framework, which is the reason for writing this blog post, simply because we wanted to share this findings and try to help and save some time to someone that encounters a similar scenario.
In our case, we were extending the TSTimesheetLine table with fields from the ResourceCategoryView view.
Next, we were extending the TSTimesheetLineEntity data entity and its staging table. On the TSTimesheetLineEntity we have also added the ResourceCategoryView as a data source and we added CategoryId field to the field list.
The AXMResourceCategoryField is not included in the staging table, because it’s the RecId relation field to the ResourceCategoryView and it is set to private in the data entity. The logic that we added here, that is nowhere to be found in the standard Microsoft Dynamics AX, for finding related record of the view in the method that subscribes to the onFoundEntityDataSource event for finding and setting the related view record is as follows:
Allow All Cookies
Third Party Embedes
Third-party cookies are cookies that are set by other websites, not this one. This website may use embedded content from other websites, such as YouTube or Google maps. Your consent is required to view content from these websites embedded on this site.