Applying grouping to Form DataSource through X++

I had a requirement at client which was related to the Shelf Advice Form:

AOT form name: PdsInventBatchShelfAdvice

Navigation:  Inventory Management > Inquiries > Batches > Shelf advice as of date

Fields to be added : 
Field                                     System name
Product name*                      (EcoResProductTranslation.name)
Expiration date                     (InventBatch.expDate)

* adding this field requires a new data source.

The required functionality was :
·         Filtering and sorting by grid should be enabled for Expiration date and Product name columns.
Therefore option of display method is not acceptable.

In the case of Product Name, the relation exists for EcoresProductTranslation with EcoResProduct table; and  EcoresProduct Table with InventTabe , but simply adding the datasources to the form and  adding fields to the grid was not enough because the groupping is being applied to the form data source at initialization of form through X++ code, 


After some effort I came accross the related class "PdsInventDimCtrlFormBestBefore" in which the methods were implemented which perform the groupping on the existing data sources such as :


these methods were being called from the form Data source init() method :


Similarly , I wrote custom methods for same purpose for my custom DataSources i.e. EcoResProduct and EcoResProduct Translation:


and initialized them in the init() method of DataSource : 



After all this I added these fields to the grid and the logic was successfully implemented and the required functionality to make the fields to be able to Filtering and sorting.

Comments

Popular posts from this blog

D365: SSRS Report Development/ Customization

D365: X++ code to add custom lookup on worker to show specific workers team workers only

Error message when you log on to a Microsoft Dynamics AX 4.0 client: "You are not a recognized user of Microsoft Dynamics AX"