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)
Answered

How to limit a EnumComboBox Fields on run time

(0) ShareShare
ReportReport
Posted on by

Hi All, 

I have an enum field. It has three values in it. Is it possible to limit it to 2 values on run time .

Please provide some code.

Thanks & Regards , 

Nishath Salman

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Yes, that's possible by overriding enter() method.

    have a look at next URL from stackoverflow

    stackoverflow.com/.../hiding-enum-elements-on-runtime-ax-2012

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

    Also consider using an two enums and an edit method, as I suggested in your previous thread.

  • Community Member Profile Picture
    on at

    Hi thanks For your Reply.

    But what I want is My Enum Field is holding an empty element ( I have not assigned the label for the element ).   So when I open the table and click the enum field combo box it is showing the blankspace and then YES THEN NO.  But I want it to show just YES and NO.

    However the empty field should also be there but When I click the Combo it should show only YES/NO.

    Please provide me some code.  And enter() I cant use as I am not using any Combo Box Exclusively

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

    That's not how enums work. If you want to be able to display {empty}, No and Yes, you're clearly talking about three distinct values, not just two. What's the problem with displaying all of them in the combobox? Also, why do you actively want to prevent users from returning to the original state after changing the value?

    If you want to ensure that no record will be saved with the empty value, use an enum with three valuesand set the field as mandatory. It means that {empty} will be a valid value of the element, but it won't be allowed to be saved in database.

    You can achieve exactly what you want by setting an invalid value of the enum, but it's not a good design. You should rather change your requirement.

  • Community Member Profile Picture
    on at

    Hi ,

    Please let me know how to hide first entry in a table for an enum field

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

    Does it mean that you don't want to use either of the two solutions above (despite the fact that you've verified them as answers)? Why not? What's requirement you have that it can't be implemented by these solutions?

  • Community Member Profile Picture
    on at

    I have Used them and all the solutions are working fine.

    I just want to know is it possible to hide first entry of the field using (initValue) override method by table level.

    In forms we can use HideFirstEntry option to do the same , however in table level how can I do so by making use of  ( initValue ) override method. Please provide me some sample .

    Bottom Line is I just want to Hide First entry in table level . Is it possible ?.

  • Ali Zaidi Profile Picture
    4,657 on at

    Use Unbound drop down and load values in dropdown at init method of form. There you can skip enum value like this.delete(enum2str(EnumType::Element1));

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

    Trying to manipulate form controls at table label makes no sense. But you could use an edit method on table. (I suggested it to you so many times that I'm getting tired of it. Did you even try it? If so, what's the problem with it?)

    initValue() is used for initializing field values (as I showed you in your previous thread); it's a completely different thing.

  • Community Member Profile Picture
    on at

    Hi thanks for your reply.  But Please Understand my question.  I want to do this Table level override method .  

    Can I Use initValue  override method of the table to accomplish the task  ..

    Please provide me sample code.

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