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

Add a field to Business central that accepts integers or Code or text or a boolean value based on a enum field value.

(0) ShareShare
ReportReport
Posted on by 81

Hi Everyone,

I am very new to Business central. 

I have a requirement where I have 2 fields 

1. Field Type and 2. Value

Field type is an enum which has Int, Text, Boolean, business object as its values

and Value will hold the default values which should be related to field type values, i.e. if int is selected in Field type, the value field should accept integers.

If Text is selected then value field should accept Text data, If business object is selected then Values field should accept any business object like warehouse or customer or vendor.

P.S: This is to allow customer to create his own parameters dynamically. Even I did not understand why we are going with this approach.

Please help me out with this as I could not find any blog that is similar to this.

Is this even possible? 

If yes then please help me out. If it is not possible then help me understand why as I should explain my Team lead.

  • Community Member Profile Picture
    on at
    RE: Add a field to Business central that accepts integers or Code or text or a boolean value based on a enum field value.

    BC or Navision needs specific data types to be defined to a field.

    it does not have any data type to be defined on the field level which can typecast itself as per the value assigned.

  • Bhaswanth Koka Profile Picture
    81 on at
    RE: Add a field to Business central that accepts integers or Code or text or a boolean value based on a enum field value.

    Business central Version 6

    pastedimage1606128027651v1.png

  • Bilal Haider Profile Picture
    248 on at
    RE: Add a field to Business central that accepts integers or Code or text or a boolean value based on a enum field value.

    Sorry I read your question again and found that you need to use this as table field. For table field unfortunately Variant is not available. You are right. I'll think on that and will provide you some way if I find.

    Regards,

    Bilal Haider

  • Bhaswanth Koka Profile Picture
    81 on at
    RE: Add a field to Business central that accepts integers or Code or text or a boolean value based on a enum field value.

    Thank you for your quick reply.

    I am trying to create a field of Variant data type, but it is giving an error that Variant does not exist.

  • Suggested answer
    Bilal Haider Profile Picture
    248 on at
    RE: Add a field to Business central that accepts integers or Code or text or a boolean value based on a enum field value.

    Hi,

    Do not worry. It is very simple. Use Data Type Variant. for your help I am sharing code here for demo.

    trigger OnRun()

       begin

           myVariant := true;

           Message('Value is: %1', myVariant);

           myVariant := 1;

           Message('Value is %1', myVariant);

           myVariant := 'Text';

           Message('Value is %1', myVariant);

       end;

       var

           myVariant: Variant;

    This code has a variable of data type variant and you can see that you can assign any value to that.

    It shows you the values on running.

    If this helps you do not forget to verify.

    Regards,

    Bilal Haider

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
YUN ZHU Profile Picture

YUN ZHU 365 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 242

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 226 Most Valuable Professional

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans