web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Making an Enum Field Go Blank when User hits (CTRL+N)

(0) ShareShare
ReportReport
Posted on by

Hi EveryOne,

I have an enum field in my table and that field is having values (None,A,B,C) respectively.

When I open the table and hit (CTRL+N) the enum field by default is selecting the value as (None).  But I want it to be go blank when I do the same (CTRL+N).  However Should be able to select values manually into the enum field.

Can Some body help me with the x++ code or steps by which I can Accomplish the scenario mentioned above.

with thanks & regards ,

Nishath Salman N.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    The default value is the enum element with value 0 (which is None in your case). If you don't want to see an empty string instead of "None", simply change label of the None element.

    If the empty value and None represent two different things, create an additional enum element.

    It's technically possible to set the field to a value not valid for the given enum (displayed as empty value), but it should be obvious that using invalid values isn't a good practice.

  • Community Member Profile Picture
    on at

    Can you please give me bit more explanation. I am really sorry but very new to ax 2012.

    So it is not possible to make the enum field go blank when I hit (CTRL+N) ?.  

    If possible please give me some sample code ...

  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    I already gave you more than one solution and I don't know which one meets your requirements, because I don't know them.

    For example, open the enum in AOT and set Label property of the None element to an empty string.

  • Community Member Profile Picture
    on at

    I got your strategy . It's working Perfectly .  Thanks a lot Martin.

    Just One More Question I would like to ask.   Is it possible to do the same by means of Code(X++).  I mean by making use any override methods ?

    Thank You :)

  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    No, not exactly the same things. Enum element labels are defined at design time and then used by AX kernel.

    You could use some workarounds, such as building the combobox control by yourself, but it doesn't look like a good idea.

  • Community Member Profile Picture
    on at

    Ok Martin Got it.  Thanks a lot Once Again  !!!!!!!!! :)

  • Community Member Profile Picture
    on at

    Since I have added an empty field it is holding three values ( 'Blank Space',Yes, No).

    But now I want it to hold just two values YES and NO.  However newly added blank Labeled element should also be there but should be displayed in the enum field combo box. Only YES or No should Pop Up ?.

    Is there any method to do it ?

  • Verified answer
    Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    If you want to display a different enum than what you want to store in the actual database field, an edit method may be a good solution.

  • Community Member Profile Picture
    on at

    One Last Question Martin Then I ll be done for the day.   I want to use initValue() method. Please provide me the code by which I can manually select any value from enum field into the combo box.

    Please do needful

  • Verified answer
    Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    Simply assign a value to the field of the active record, such as MyDatasource.MyEnumField = MyEnum::No;.

    If your question is answered, please mark the corresponding reply (replies) as the verified answer.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans