Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Change custom fields type from Option -> Enum

(0) ShareShare
ReportReport
Posted on by 2
Hi,
 
     I was wondering if Microsoft is changing standard Option fields into Enum, should we do it also?
 
In BC25 Could version we have this field:
 
 
This is clearly an old field that before was an option and now is an Enum. If I open the sales order, is still option as it was originally.
 
 
If I Check Fields table: 
 
OptionMembers = TableFilter,RecordID,OemText,Date,Time,DateFormula,Decimal,Media,MediaSet,Text,Code,Binary,BLOB,Boolean,Integer,OemCode,Option,BigInteger,Duration,GUID,DateTime;
There is No ENUM in this list.
 
For the breaking change Microsoft says:
This statement is a warning and is related to when you make a new field of type Enum and copy values from Option. As long as Option and Enum have same values, this warning should be no problem. Also, I tried, and changing custom fields from Option to Enum is nor an error or warning for AppSourceCope, also deploying change into Cloud environment the existing values in Option field are not lost.
 
Still I have this Question:  Is it a breaking change if I Replace Option type of field with Enum directly, NOT to create a new Enum field and copy values from Option, that Microsoft says in the above link is a warning.
 
 
 
  • Suggested answer
    Inkey Solutions Profile Picture
    Inkey Solutions 1,900 on at
    Change custom fields type from Option -> Enum
    Hello, 

    If the field data type is either Enum or Option, it will always appear as an Option in the table field of Business Central.

     
    When replacing an option field with an enum field, the ordinal values must match those of the original option members. Changing these values can cause data inconsistencies and corruption during upgrades. Additionally, extensions relying on specific ordinal values may fail if altered in the enum field.

    To resolve this error, follow these steps:
    1. Locate the enum field in your code that is replacing an option field.
    2. Ensure that the ordinal values of the enum members match those of the original option members.
    3. If the ordinal values don't match, adjust the enum members to preserve the original ordinal values.
    Thanks.
  • gdrenteria Profile Picture
    gdrenteria 13,350 Most Valuable Professional on at
    Change custom fields type from Option -> Enum

    Hi, good day
    I hope this can help you, and give you some hints. It's time to Enumify your Option fields in AL and Business Central

     

  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 7,144 on at
    Change custom fields type from Option -> Enum
    Replacing an Option with an Enum is safe if you preserve the same ordinal values (order and numbering) of the original Option members. 
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    Kamal Khakhkhar 313 on at
    Change custom fields type from Option -> Enum
    Hii there,
    As per requirement you can update data type from option to enum it's not make any error. You need to add all the options members to enum and then update the some of code as per enum . It will work. Even though you are worried about your data create new field . Move data to that field and obsolete the old field.
     
    Thank you.
    Kamal Khakhkhar
  • Suggested answer
    Bilal Haider Profile Picture
    Bilal Haider 113 on at
    Change custom fields type from Option -> Enum
    Hi,
     
    Interesting post! I never noticed that in page inspection the document type shown is still option although in table definition its an enum. 
     
    If you are replacing option type with enum then it is actually recommended by Microsoft. Also using enums make our lives easy as then we need to maintain only at one place. like if a new value is added, or value is being updated.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Share Your Event with the Community

Jump start your event engagement! 📢

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,717 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans