Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to avoid using Hard coded values in code in AX 2012 developement

Posted on by 950

Hi there,

I want ot use some of set up table data in my code and validate and take some action on selection particluar values.

e.g. Asset major Group has type as Cars then i need to do some action at code level.

How can i avoid using this type = Cars in my code?

Is there any other approch to use such values in code?

 

Regards,

Rahul

*This post is locked for comments

  • Suggested answer
    Joris dG Profile Picture
    Joris dG 17,775 on at
    Re: How to avoid using Hard coded values in code in AX 2012 developement

    Depending on the scenario and meaning of this, we typically use one of three scenarios:

    1) make a parameter table, or add a parameter to an existing parameter table where the user can select the type. This assumes that type is mostly static and has a special meaning.

    2) on the setup of the asset group, or if the cars type is a lookup and not an enum, add a checkbox where users can indicate which types have that "special meaning". Again, this assumes that type to be used is mostly static

    3) if this needs to be dynamics and can change depending on the user's needs at that very moment, prompt a dialog to ask for the type

  • Suggested answer
    Muhammad Yasir Profile Picture
    Muhammad Yasir 1,023 on at
    Re: How to avoid using Hard coded values in code in AX 2012 developement

    you can make an enum for the value that is to be matched.

    Yasir.

  • Pranav Kumar Profile Picture
    Pranav Kumar on at
    Re: How to avoid using Hard coded values in code in AX 2012 developement

    You can use paramteric setup like creating a new field in FA parameter and validating against the value in field rather than hard coding.

    Pranav

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans