5

Is there a table, view, or procedure I can use to extract the values from a Base Enum using SQL (straight from the DB, not within X++)? I was able to find an isolated few in the table SRSAnalysisEnums but not the enum I need in particular.

Luke Wyatt
  • 1,126
  • 2
  • 12
  • 23

3 Answers3

4

Looping over enums is dead easy:

static void EnumIteration(Args _args)
{
    DictEnum enum = new DictEnum(enumName2Id("TestEnum"));
    int i;
    for (i=0; i < enum.values(); i++)
    {
        info(enum.index2Label(i));
    }    
}

Roll it on your own table.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • This helped me checking if a string value matches one element of an enum. Comparing my string with all the labels of elements has a meaning in my scenario so this is great. Thanks Jan! – Olaru Mircea May 05 '16 at 07:44
4

If you are trying to access the Enums from outside AX (for example in sql) you can add the missing enums to SRSAnalysisEnums by adding the containing table to a perspective and rebuilding the models

Tools->Reporting tools->Update models

It is described here http://abraaxapta.blogspot.co.uk/2012/02/missing-enums-in-srsanalysisenums.html

And an different AX2012-only way of doing it

http://abraaxapta.blogspot.co.uk/2012/11/accessing-enum-labels-from-outside-ax.html

Hope this helps

David Lawson
  • 796
  • 3
  • 10
  • This did the trick (2012 version). I only had to modify the query to iterate through the enum indexes and stored the values in a temp table. – Luke Wyatt Jan 09 '13 at 18:53
  • Another reference for 2012 would be: http://ioi.solutions/retrieving-label-from-enum-value-in-dynamics-ax-sql-db – Mark Freeman Apr 13 '16 at 17:12
2

SELECT A.ENUMITEMVALUE, A.ENUMITEMLABEL AS ENUMITEMNAME FROM [DBO].SRSANALYSISENUMS A WHERE A.ENUMNAME = 'LedgerPostingType' AND A.LANGUAGEID = 'en-us'

straight from SQL table

Nath Pham
  • 43
  • 4