How to Range OptionString values

Dear All,

I want to get sublist of values from my OptionString.I tried by assigning option index (ie,0,1,2,3) but din’t get the Range of value as i expect. Please help me…

e.g I have 2 Drop Down List.I want to show only selected values in my 2nd Dropdown list depending on the 1st Drop Down List Value.

I w’d Appreciate if anybody can answer[:(]


Dear Rose,

It’s not possible to change the OptionString on run time. Instead you can predefine different options which should used depending on the value of your first option field. In my example below I have a field (Option1) with the values A to D. And then I have created 4 fields (Option2A to Option2D) and depending on the value of Option I either hide or display the correct Option2 field.

CurrForm.Opt2A.VISIBLE(Option1 = Option1::A);
CurrForm.Opt2B.VISIBLE(Option1 = Option1::B);
CurrForm.Opt2C.VISIBLE(Option1 = Option1::C);
CurrForm.Opt2D.VISIBLE(Option1 = Option1::D)

I have also attached the objects so that you can test it your self.
Options.txt (2.46 KB)

Thanks Erik.

But this will not solve my Problem.

I will Explain the situvation

I have a Set of values {10,20,30,40,50) in my First Dropdown List

then i have another set of values(which should come under the above ) in my second Dropdown List{100,101,102,103…110,200,201,202,203…210 etc}

when i select ‘10’ from the 1st drop down list ,then my Second Drop down List should display {100,101,102,103…110}

if i select ‘20’ then{200,201,202,203…210} and like that

Please help me how to solve this

Thanks & Regards


Hi Rose,

I cannot see how it will not solve your problem.

You create two versions of your second dropdown list. On including 100,101,102,103…110 and one including 200,201,202,203…210. And just follow the same steps as above.

But I have a different question. Why do you want to use the option fields for this? To me the values look more like something you shouldn’t be hard coding into your solution. Instead you could use a table for both option 1 and 2, where table two would have the option 1 key as the first key.

The general advise regarding option fields is that they are only to be used for very simple and very static values. Option fields in general should never carry real information. But then again I don’t really know what the values are representing.

You are looking for dropdown box behavior that is seen in other development tools, such as the dropdown box in MS Access, or in the Winform designer in Visual Studio. This is simply not possible in NAV. Option type fields are defined at design time, you can’t change values at runtime, and they don’t have indexed values either.

Internally, an option type variable is stored as an integer. I always have to check to see if it starts at 0 or 1.

The way you would do what you are trying to do is either by following Erik’s advice (you should really try to make that work instead of dismissing it right off the bat), or create a couple of tables that you can filter. It is simply not possible to have a dynamic dropdown box in C/SIDE.

Hi Daniel,

It’s good that at least some of us knows programming outside of the NAV world! I really didn’t know what Rose was trying to do, or should I say, why?

I remember having the same question when I started out [:D], I used to work with VBA quite a bit. Seems like somewhere a bunch of VB programmers were put to work on a NAV project.

Hehe that’s great! VB wasn’t really around when I started with Navision. Back when I learned programming everything was character based. I learned Pascal (Poly Pascal and Turbo Pascal - which was really big back in the 80’ies - same language the guys who made Navision knew) and Cobol - which actually also was a great language for programming business applications. Very structured!

So all this fancy stuff you can do with forms and controls in the Windows world I never learned.