✏️ Explanatory Question
In X++, you can use the select statement along with order by to fetch records based on specific conditions. Here's how you can select the first record from the newMarkupTrans table, ordered by LineNum in descending order, and filter it using TransTableId and TransRecId:
select firstOnly LineNum
from newMarkupTrans
order by newMarkupTrans.LineNum desc
where newMarkupTrans.TransTableId == _origMarkupTrans.TransTableId
&& newMarkupTrans.TransRecId == _origMarkupTrans.TransRecId;
select firstOnly: Fetches the first matching record.order by newMarkupTrans.LineNum desc: Orders the results by LineNum in descending order.where newMarkupTrans.TransTableId == _origMarkupTrans.TransTableId && newMarkupTrans.TransRecId == _origMarkupTrans.TransRecId: Filters the records where the TransTableId and TransRecId match the values from the _origMarkupTrans table.firstOnly: Retrieves only the first record matching the criteria.order by: Sorts the results in a specific order, in this case, descending by LineNum.