ValuesAllowed property in BC

I was working on a task where it was suggested to create an Option field so we had a shorter list of values available to users. When I got into the nitty gritty of development and was trying to set the value from an Enum I was getting a warning “An implicit conversion is being performed from a value of type ‘Enum xxx’ to a value of type ‘Option’. This conversion can lead to unexpected runtime issues. This warning will become an error in a future release.” I know there are ways to do conversions, but do I really need to use an option? Wouldn’t it be nice to just use the Enum?

I then stumbled across the ability to limit the (enum) values available to users. You can set this with the ValuesAllowed property on Tables or Pages. All you have to do is separate the values with a comma.

A few caveats:

  • The ValuesAllowed are only limited via the User Interface. Even if I set the property at the Table level, as a developer writing code I would still have access to all of the values. The validation would only get hit through the UI.
  • You can only set this value for custom fields. If you try to set this on a field from another app, you will get an error that The property ‘ValuesAllowed’ cannot be customized.
You cannot set the ValuesAllowed property on fields from other apps.

That being said, when I was working on some code today I created a new field with a type of a Base Enum. I was able to set the ValuesAllowed for that specific field, as you are not limiting values of the Enum being used throughout the system, just on that specific table or page.


You can also set this property on other field types. I am not saying this is something you should implement, since a developer would have to maintain the values that are allowed, but it’s available to use.

Say you want to track the probability of a Quote becoming an Order. One could argue that you could create an Option or Enum. Instead let’s create an integer field that only accepts values of 0, 25, 50 and 100.

Added a Probability [Integer] field to a page, where thet ValuesAllowed are st to 0, 25, 50, 100.

If you were to enter a value of 33 on the page, you would receive an error message, and it would display the values that are accepted in that field.


Overall, I find this property pretty handy. It worked well for limiting values on a new custom field without doing conversions between Options and Enums, and I didn’t have to create an entirely new Enum. Reusability at it’s finest.

#msdyn365bc #businesscentral #bcdevelopment #development

Leave a comment