AX Sorting in Table Column ( Enum Label)


I have to return a table data based on a column sorting. it is pretty much simple.

dataSource.addOrderByField(FieldNum(Table,EnumColumn), SortOrder::Ascending);

problem is that sorting column is a Enum Type and AX saves its int value in db & i have to sort on its Label value.

what i found so far is to “add a view on table, add a column with Enum label, then sort on View data”

but in this case i creating a view just for sorting purpose. which is not a good solution when are working on big product :slight_smile:

Is there is any other quick solution for this?

The order will be different in different languages - do you want to support more than a single language?

no, i just want to sort a table data (sorting col datatype is Enum), problem is that i have to sort on Enum Label value not on Enum value(int).

Yes, I know. I’ll try to explain it in better details.

Take NoYesCombo enum as an example, to keep it simple. It has only two elements, No and Yes, with values 0 and 1 and label IDs @SYS2048 and @SYS5461. In Czech, the labels are Ano and Ne, therefore the sorted values will be {1, 0}. In English, on the other hand, the labels will be Yes and No, therefore the sort will be {0, 1}.

Is it now obvious that labels, and therefore sorting, depend on language?

thanks for detail…

in that case, only English is required.

The most efficient option, in my opinion, is changing the enum or creating a new one. It will have the same elements, but its values will be sorted according to English labels.

If the enum may be extended in future, keep some gaps between values (e.g. 10, 20…).