maxof( fieldid2name( … ) ) from tableid2name( … )?
Question
is it possible to get the current max-value of a column, only knowing tableID and fieldID in ax 2009? i know you can get several informations about the field like isMandatory or something, but i need to know the maximum value instead...
thanks for any hints in advance!
Solution
No problem if you program your query, look at this job (AX 2009):
static void MaxValueTest(Args _args)
{
str maxValue(TableId tableId, FieldId fieldId)
{
QueryRun qr = new QueryRun(new Query());
qr.query().addDataSource(tableId).addSelectionField(fieldId, SelectionField::Max);
return qr.next() ? any2str(qr.get(tableId).(fieldId)) : '';
}
;
info(maxValue(tableNum(CustTable), fieldNum(CustTable,AccountNum)));
}
One problem is the return type, which is solved by casting to string.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow