Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

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

(1) ShareShare
ReportReport
Posted on by 1,858
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 230,370 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,858 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 230,370 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,858 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,738 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,347 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,858 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,738 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,858 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,347 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans