Some times we need to find an unique record from a table. In this example I'm find an unique record based on created date time and grouping by salesId. Change the code according to your requirement.
Usually we use this format code when the primary index is not available in the table.
while select maxof(LogCreatedDateTime) from SalesOrderLogView
join salesTable
group by SalesOrderLogView.SalesId
where SalesOrderLogView.LogCreatedDateTime >= _fromdatetime
&& SalesOrderLogView.LogCreatedDateTime <= _todatetime
{
info(SalesOrderLogView.salesID);
}
@Rahul
Usually we use this format code when the primary index is not available in the table.
while select maxof(LogCreatedDateTime) from SalesOrderLogView
join salesTable
group by SalesOrderLogView.SalesId
where SalesOrderLogView.LogCreatedDateTime >= _fromdatetime
&& SalesOrderLogView.LogCreatedDateTime <= _todatetime
{
info(SalesOrderLogView.salesID);
}
@Rahul
Very useful breakdown on handling records in D365 X++. The way you explained grouping by SalesId with maxof(LogCreatedDateTime) makes it much clearer for those of us who sometimes struggle with missing indexes. Thanks for sharing such practical code snippets! By the way, if anyone here also enjoys exploring tools outside of Dynamics, you might find steam idle master interesting it is handy for gamers who want to maximize their Steam card drops.
ReplyDelete