Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Add Enum Values to Lookup

Posted on by Microsoft Employee

Hello everybody,

on SalesEditLines form of Dynamics AX 2012 under Designs > tabParameters > tabPageParameters > groupUpdate I have create a StringEdit field. I have overridden method lookup() of this field and I need to add at lookup's drop down some values of an Enum (so far I used SysTableLookup Class which adds table's values based on a query)

For example, I have created Enum TestEnum with values TestEnum::Test1 TestEnum::Test2 and TestEnum::Test3. I would like to know how to add at StringEdit's lookup TestEnum::Test1 and TestEnum::Test2

Kind regards,

Michalis

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Add Enum Values to Lookup

    Dear AX 2012 r3, all right, I'll leave that reply in place, so everybody can you see what you call a solution. But don't spam this forum again with these links.

    I don't see what code I should provide for creating a new enum; you're likely just trying to to take the attention off your post. I suggest you either find a more productive way to participate to this forum, or you go somewhere else.

  • AX 2012 r3 Profile Picture
    AX 2012 r3 2,420 on at
    RE: Add Enum Values to Lookup

    What i have given is  a suggestion.

    In all your replies have you given exact code what other requires.?

    Everyone gives examples.

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Add Enum Values to Lookup

    Consider simply creating an enum with values you need (A, B and C). Then AX would build the lookup for you and you wouldn't have to write any complex code for it.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add Enum Values to Lookup

    I use EditString and lookup() method because if I use a Combobox bound at an Enum values are messed up if I try to delete a value that other values follow. For example let's say there is an Enum with values A, B, C, D. If I delete value D then everything  is ok but if I delete B then C index changes and even though value C will be chosen in database it will be written as index 2 which is value B

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Add Enum Values to Lookup

    I was answering your question "Can you please explain how can I create a new TmpDB or InMemory temporary table?".

    If you want a lookup for a string field, you need a table with a string field (not necessary a new one). But what's the point of having a string field and building a lookup based on an enum? Shouldn't you use an enum instead of a string?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add Enum Values to Lookup

    Martin, I would like to avoid creating a new table in Database with just one Enum column just for this purpose. That's why I would like to know if there is a way to use an Enum's values as a lookup for a form's field. Probably with SysLookup Class

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Add Enum Values to Lookup

    Michalis, if you know how to create a table, you're almost done. Just change its Table Type property.

  • Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Add Enum Values to Lookup

    Hi AX 2012 R3, your link merely points to a certain site, not even a specific article. Can you please point out where exactly is contains the answer to Michalis's question?

    If you're merely trying to promote the site and not to answer the question (I saw you giving exactly the same link at some other place), please stop it.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add Enum Values to Lookup

    Can you please explain how can I create a new TmpDB or InMemory temporary table?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add Enum Values to Lookup

    Thanks for your quick replies.

    Is there a way to achieve my goal with SysLookup Class instead of SysTableLookup Class?

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

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans