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)

How to show default value of enum type field on form

(0) ShareShare
ReportReport
Posted on by 515

Hi can we show default value of enum field on form whoose who is not 0th element of enum. Also if user cchanges the value then it should not change it back to default one whoch we had set earlier.

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Hi Dhansri,

    Can you explain more in detail is the enum is based on a able field or if it is an unbounded control? If it is a table field, you can override the initValue method on the table to set the initial value.

  • Community Member Profile Picture
    on at

    If this is the table field you can set default value in "Create" method of the form. "Create" method get calls each time when you create a new record in form. If it is not a table field then you can set default value in "init" method of the form. 

    If you want set default value after modification also, then you can override the "modified" method of the field and write related code. 

  • Viral Suthar Profile Picture
    279 on at

    Hi Dhanshri,

    Agreed with Akshay, if its a bounded field then you can set the default value of enum in create method of datasource in form and if its an unbounded field you can set the default value every time when the form is initialized.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    You can show the default value, You can change the previous selected value also after user modified the value.

    Please explain me exact what do you want? if you want to assign the previous selected value after modifying the value you can do that.

    Thanks

    Sunil

  • Dhanshri Profile Picture
    515 on at

    Hi All,

    My requirement is on Account receivable form I have to show new enum field "Reservation priority " and its value should be defaulted with value 6 which is having Enum value =6.

    I tried with the below solution and stuck due to different issues.

    1. I can set the value to 0th position and get expected value as default value but the issue is I can't change the sequence of pre defined enum.

    2.I tried to write code on table->initvalue method. but as I want to show the value on AR parameter form it is not invoking that function.If I create the record in table from AOT then it is showing expected value in enum but not getting same result when I am trying to create record on form.

    Kindly let me know if it is possible or not. If so kindly suggest the way.

  • Suggested answer
    5400 Profile Picture
    7,162 on at

    Don't change the existing enum value. if it is standard enum impact will be high.

    you can add this enum field in salesparameters table and write one line code in there

    \Data Dictionary\Tables\SalesParameters\Methods\initValue

    this.yourfieldname = Enum::value

    Same you can populate in salestable how journalType is getting populate through parameters.

  • Dhanshri Profile Picture
    515 on at

    Hi Bhaskar,

    If I write the code on Saleparameter table it will show me the default value when I will create new record in AR parameter but I want to show it by default when we open the AR form and also if user is changing its value then it should then display the modified value.

    Can we achieve this?

  • 5400 Profile Picture
    7,162 on at

    Yes why not. so you can set the default value in parameters and when you open the AR from take the parameters value as default through code and check the recversion before assign the value.  

  • Dhanshri Profile Picture
    515 on at

    @ Bhaskar - I didn't get you clearly..

  • 5400 Profile Picture
    7,162 on at

    Let me say point by point

    1. Set the value in parameters as default

    2. Same value you can take it in AR or whatever (caller) UI during insert

    3. If user update after insert reversion will get update when data was inserted first time reversion field in table will be 1.

    4. When you will open the UI defaulting logic should be depends on reversion.

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