tags:

views:

65

answers:

1

hey folks,

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!

A: 

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.

Jan B. Kjeldsen
thanks a lot ;)
Nico