web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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.

I have the same question (0)
  • Suggested answer
    Bilal Haider Profile Picture
    442 on at

    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

  • Bhaswanth Koka Profile Picture
    81 on at

    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.

  • Bilal Haider Profile Picture
    442 on at

    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

    Business central Version 6

    pastedimage1606128027651v1.png

  • Community Member Profile Picture
    on at

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,958 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,101 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans