Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to get Enum Name o...
Finance forum
Suggested answer

How to get Enum Name of the Field which has type 4 in SQLDictionary Table

Posted on by 1,843
Hi,
 
SQLDictionary table has a column FieldType. In this column the value 4 Represents Enum.
 
How Can I get the Enum Name behind the the fields which has the value 4? Is there any table which has the fieldname and Enum Name relationship?
 
Appreciate any tips
 
Thanks
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 228,501 Most Valuable Professional on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    In SQL, you could look at the data type of the view field (every data entity is implemented as a view in the database).
     
    Regarding your code, you need to look at properties of the entity field (fieldsEnumerator.Current) instead of just calling its ToString() method.
     
    Note that the AOT Browser already gives you this information, and if you don't want to use AOT Browser as such, you can look at the code (because it's open source) rather then trying to implemented the same thing again on your own. It's in ARBEntityFieldPopulateService class.
  • MYGz Profile Picture
    MYGz 1,843 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    Couldn't get past this. Which reflection method works on the DataEntity to get the field type and field length. Can it be achieved via TSQL? SQLDictionary is only missing the Enum Name and FieldName relation.

    The goal is to build the excel template for entities along with all the fields, its data type and length and values of Enums. Further Field description column would be written manually.
     
    public static void main(Args _args)
    {
    
        var entityNames = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetDataEntityViewNames();
        var enumerator = entityNames.GetEnumerator();
    
        while (enumerator.MoveNext())
        {
            var EntityName = enumerator.Current;
            Info(strFmt("The Entity Name is %1",EntityName));
    
            var DataEntity = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetDataEntityView(enumerator.Current);
            var dataEntityFields = DataEntity.Fields;
            var fieldsEnumerator = dataEntityFields.GetEnumerator();
    
            while (fieldsEnumerator.MoveNext())
            {
                var FieldName = fieldsEnumerator.Current.ToString();
                Info(strFmt("The First Field Name is %1 : Field Type is %2",FieldName, typeOf(fieldsEnumerator.Current)));
                break;
            }
            break;
        }
    
    }
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 228,501 Most Valuable Professional on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    You can use the metadata API to get information about table fields, e.g. the enum name.
     
    Element IDs of extensible enums are specific to each environment; you must look into EnumIdTable and EnumValueTable tables. SrsAnalysisEnums isn't sufficient in all cases, as far as I know.
     
    Regarding your last questions:
     
    1) First of all, learn how to iterate entity fields and look at their properties. Later we can optimize it, e.g. to avoid the iteration.
    2) String length is defined by the EDT (and its extensions).
    3) Answered above.
     
    It would help if you explained what you're trying to achieve, because some approaches may be more appropriate for your (unknown) goal than other or you might even utilize existing tools (such as AOT Browser).
  • MYGz Profile Picture
    MYGz 1,843 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
     
    Though I am able to get the Entity Name and Fields from code in this blog:
     
    How do I get the:
    1. Field Type providing the entity view name and the field name to some Metadata function?
    2. Field Length if it's a string or edt.
    3. Enum values if it's an enum.
     
     
    Thanks.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 9,316 Super User 2024 Season 2 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    Hi @MYGz,
     
    In this case you must use x++ to identify the details.
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Layan Jwei Profile Picture
    Layan Jwei 7,071 Super User 2024 Season 2 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
  • MYGz Profile Picture
    MYGz 1,843 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    @Mohamed
     
    Thanks, but that's just Enum details. What I'm looking is the field name and enum name relation when the field type is Enum.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 9,316 Super User 2024 Season 2 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    Hi @MYGz,
     
    all the enum name and item name are stored in SRSANALYSISENUMS Table.
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • MYGz Profile Picture
    MYGz 1,843 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    Hello Martin,

    I would prefer TSQL but X++ will also do. I'm just looking for a solution. My goal is to get all the entity names and it's fields along with datatypes and constraints in case of string and enum name (sorted in ascending enum value) in case of enums.
    I'm starting with 2 tables DMFEntity and SQLDictionary. Is there a better approach than to start with the above 2 tables?
     
    I'm stuck on 2 steps.
    First is as mentioned in this question.
    Second is to get all the DMFEntity names. Although DMFEntity provides all the entity names but when joining it with SQLDictionary table there are duplicates. I'm trying to remove the duplicates but still some of them are still there.

    @Layan I'm looking for bulk operation not just 1 table or few fields.

    Thank you for the replies
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,071 Super User 2024 Season 2 on at
    How to get Enum Name of the Field which has type 4 in SQLDictionary Table
    Hi,
     
    If the enum is not extensible, you can simply open the enum in visual studio and look at the properties to see the number that represents each enum value.

    However, if the enum is extensible, you can look at EnumIdTable and EnumValueTable to get the Enum values
     
    Thanks,
    Layan Jweihan 
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

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.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans