Hello guys,
In regards of calculated column, which the programming a bit different than X++, how to get a label of an Enum inside a calculated Column ?
Thanks
If I understand correctly, you would like to get a label of an enum value in T-SQL (in a computed column).
You can read it from SRSAnalysisEnums table.
By default it contains only English label. But you can use cross references to see where the table is populated, and add your own logic for adding other languages if you need.
Hi Nikolaos,
Noted the table, however the label is not populated and it is on purpose (by Microsoft).
My options is to populate that or in my data entity, as this is my own custom, is the one should get the label for my specific enum.
I choose 2nd, but kinda stuck in the code, because it looks like we cannot mix X++ in Calculated column, am I right?
Any chance of succeed on this attempt?
Computed columns are not executed by D365 and can't contain x++ code.
If you want to use a computed column, your solution must work in T-SQL.
I think that SRSAnalysisEnums is intended for this exact purpose. And you can populate it with your labels.
You can use SysComputedColumn::switch() to generate T-SQL CASE statement mapping numeric values to label texts. For example:
public static str computedColumn() { SysDictEnum dictEnum = new SysDictEnum(enumNum(MyEnum)); Map mapping = SysComputedColumn::comparisionExpressionMap(); for (int i = 0; i < dictEnum.values(); i ) { mapping.insert( SysComputedColumn::comparisonLiteral(dictEnum.index2Value(i)), SysComputedColumn::returnLiteral(dictEnum.index2Label(i))); } str comparisonField = SysComputedColumn::comparisonField( tableStr(MyEntity), dataEntityDataSourceStr(MyEntity, MyTable), fieldStr(MyTable, MyField))); return SysComputedColumn::switch( comparisonField, mapping, SysComputedColumn::returnLiteral('')); }
Hi Martin,
Much appreciated for your code. It works!
Thanks.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,004
André Arnaud de Cal... 857 Super User 2025 Season 2
Sohaib Cheema 548 User Group Leader