Hiding enum values

twujstary
Member Posts: 3
Hello,
I am currently working with the newest version of Business Central.
I have created an enum, let's say Enum "Colours" with following values:
• Red,
• Violet,
• Yellow.
Afterwards, I want to create two tables with field "Colour" of type Enum "Colours".
In the first table I want to have all colours available, so the end-user could see: Red, Violet and Yellow as an option.
The second table I would like to have only two of these colours, so the end-user see: Red and Violet.
Is it posible to hide enum values for other fields?
or the only solution is to create two enums - one containing all of the options and the second one, containing only two of these colours?
I am currently working with the newest version of Business Central.
I have created an enum, let's say Enum "Colours" with following values:
• Red,
• Violet,
• Yellow.
Afterwards, I want to create two tables with field "Colour" of type Enum "Colours".
In the first table I want to have all colours available, so the end-user could see: Red, Violet and Yellow as an option.
The second table I would like to have only two of these colours, so the end-user see: Red and Violet.
Is it posible to hide enum values for other fields?
or the only solution is to create two enums - one containing all of the options and the second one, containing only two of these colours?
0
Best Answer
-
Try ValuesAllowed property.
For example:
1
Answers
-
Try ValuesAllowed property.
For example:
1 -
Hello yzhums,
thank You for your response. It works as intended.
But it's a little bit problematic, because let's say that after a while there is a new colour: Orange. So I am typing a new value to Enum Colours. So now I have to remember to go to each table, which uses this enum and add another allowed value, to those fields. Right?
I didn't find a way to define not allowed values, for specific field, that would be a little bit easier to maintain. Do You know a way to do that?0 -
Yes, as far as I know, this should be the only way. Because ValuesNotAllowed Property does not exist in the BC.
If you don't hide the value, you can control it in the OnValidate trigger. That might be simpler.
Since you have to add the value of Enum in VS Code every time, you can maintain this property by the way.
It may be simpler to refer to the following method.
0 -
Yes, I know about references, but I will rather go with creating new Enum instead, I guess.
Imagine using this particular enum for 500 different fields In that case you would have to analyze each field individually - either you want new value or not.
In my opinion it's easier to have few enums - maybe it's uglier solution, but I have to think in a little bit bigger perspective.
Thank you for your time though.1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions