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 :
Small and medium business | Business Central, N...
Suggested Answer

Filter an enum depending on the value of another enum

(0) ShareShare
ReportReport
Posted on by 10

Hello everyone! 

I would like you to help me with this that I have been giving you head and I do not see how to do it. 

I have two enum, and I would like the values of one to depend on the other.

For example: I have an enum, which has if it is Type Vehicles: Car or Jeep. And another enum that continizes the Vehicle Brands. 

If I select the car type, I would only like the values for the enum 1,2,3 to be displayed. And if the Jeep vehicle type is selected, the values 4,5,6 are displayed.

Everything belongs to the same table.

Is this possible?

Enum-1.jpg

Enum-2.jpg

I have the same question (1)
  • Suggested answer
    Alok.kulshreshtha Profile Picture
    934 on at

    Hi,

    Apply a filter to display some of enum values based on other enum is not possible. system will display all values in dropdown.

    Alternate-

    1. add a restriction on "on validate" trigger for Brand type. with below code use will not be able to select  4,5,6 for type Car and 1,2,3 for jeep

       trigger OnValidate()

         begin

             case rec."Vehicles Type" of

                  rec."Vehicles Type"::Car:

                   begin

                      IF NOT (rec.Brand IN [rec.Brand::Toyota,rec.Brand::Honda,rec.Brand::BMW]) then  

                         Error(StrSubstNo('%1 is not allowed for %2',rec.Brand,rec."Vehicles Type"));

                   end;

                  rec."Vehicles Type"::Jeep:

                   begin

                      IF NOT (rec.Brand IN [rec.Brand::Volvo,rec.Brand::Chevrolet,rec.Brand::Nissan]) then  

                         Error(StrSubstNo('%1 is not allowed for %2',rec.Brand,rec."Vehicles Type"));

                   end;

             end;

         end;

    2. Use Table to store Brand. either create a new table with column Brand and Type or you can also try with dimension and dimension value table. with use of table relation property you can filter brand list and show as per  Vehicles Type

    Regards,

    Alok Kulshreshtha

    Please verify if you find my answer helpful

  • Angel Manuel Reynoso Profile Picture
    10 on at

    Thanks you Alok!

  • Suggested answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at

    Hi, as I replied to you on twitter, you can try adding the same field multiple times, and then use a variable to control the displayed field.

    pastedimage1652660668536v1.png

    Because valuesAllowed property can apply to Page Field.

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-valuesallowed-property

    pastedimage1652660792267v2.png

    Hope this helps

    Thanks.

    ZHU

  • Suggested answer
    Alok.kulshreshtha Profile Picture
    934 on at

    Hi,

    if you feel my post help you to answer your query, please verified answer so It will let others know that the topic has verified answer and was beneficial to you.

  • MAURICIO V ALVAREZ Profile Picture
    5 on at

    Your Solution ZHU works perfectly for me. Thanks.

    [quote user="ZHU YUN"]

    Hi, as I replied to you on twitter, you can try adding the same field multiple times, and then use a variable to control the displayed field.

    pastedimage1652660668536v1.png

    Because valuesAllowed property can apply to Page Field.

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-valuesallowed-property

    pastedimage1652660792267v2.png

    Hope this helps

    Thanks.

    ZHU

    [/quote]

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,226

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,047 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,257 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans