You might have had a requirement to provide only the last record by CreatedDateTime field from a custom data entity, but you couldn’t accomplish it with what would be obvious solutions to the problem, i.e.:
So the solution would be to use view as data entity data source and create a computed column with ranking based on the CreatedDateTime field from the data source from which we want to select the first only record.
Add the following method for the computed column in the code of the View:
public class WorkflowTrackingView extends common
{ public static server str compColRankByCreatedDateTime()
{
str ret;
DictView dv =new DictView(tableNum(WorkflowTrackingView)); ret = 'RANK () OVER (ORDER BY '+dv.computedColumnString('WorkflowTrackingTable', 'CreatedDateTime')+' DESC)';
return ret;
}
}
The next step would be to use this new field on the data entity as a range with value of 1 as according to the computed column our latest record would be of rank 1.
And voila, you have a first only function on a data entity 😊
YOUR GLOBAL DELIVERING DYNAMICS PARTNER
YOUR GLOBAL DELIVERING DYNAMICS PARTNER
© All rights reserved • Axapta Masters