List Box

Dear all,

please tell me How to use List Box Control?

My purpose is to display a set of values(of type Code) in this Control. or please tell me how to convert Text value to Option Type.I can’t assign text to option at runtime.

Please hep

Rose.

As far as I know, there isn’t such a thing like List Box control in Navision. Why do you want to convert a text value to option?

I dare to guess - you have a field which may contain a value chosen among a predefined set of values. You want the user to be able to look at a list of those predefined values and choose one. You don’t want the user to be able to add more values to the list.

If this is the case you have two options:

  1. As you already are trying, you may use a Option field. This means you will have physically on you table an integer value, which will be shown to users as a text. The content of the text variable is hard coded in the OptionString property of the field itself. It can be translated through the OptionCaptionML property, but it cannot be changed at run time. A specifical value can be referred as MyFieldName::Value or with its integer value. The text value in the MyFieldName::Value expression must be one of those defined in the OptionString property. You may get the current text value (according to current language) of an option field using the FORMAT function. If you have different languages and values in the OptionCaptionML the value returned by the FORMAT function might not be the same as the corresponding value in the OptionString - which sometimes is annoying.
    In my knowledge there is no easy way to convert a text value into the corresonding integer value. Whenever I had to do something like that always ended using a CASE group and hating it.

  2. You may use a Code field.
    Create a table MyValues with a code field as the primary key and whatever attribute you may want to assign to it (maybe a description?). Create a tabular form on the MyValues table including all the fields of the table. This form will be used to fill the table with the values you are presently trying to assign to an option field. You will put it on a menu to which only authorized users have access - you might even use the Run function from object designer to fill the table if you think that the content of the table will never need to be updated, after the first time.
    Create a tabular form based on MyValues table showing code, description and whatever else you like. In this form set the Editable property to No. In the table set the form number as the LookupFormID and DrillDownFormID property.
    Add a code field wherever you need it and set MyValues table as the TableRelation property of this field. Add the field to any form - you need nothing more.

Dear “Rose”,

I’m not trying to answer you. I will just be quoting Daniels reply to you of yesterday. I don’t think that you read his reply.

Let me just make a few things clear about NAV:

Dynamics NAV is not Visual Basic and you cannot do the same things in NAV that you can do in VB.### NAV, C/SIDE and C/AL is not a development language, but a business application platform designed to be able to easily modify and extend the standard Dynamics NAV application.### Most of the best NAV developers I have met over my 19 years of working with Navision did not have a background as programmers, but had a business/accounting background. To be a good NAV developer, requires that you understand the business.

You should really read the answers that you got in the other threads that you started about converting and selecting option values. You should stop trying to build values in runtime, NAV just doesn’t work that way. Instead of trying to make NAV behave like a Visual Studio form, try to learn how NAV works, and how to use C/AL, instead of trying to translate that directly.

Like Anna said, there is no control called “list box”. The only type of list that you can use is a table box, which is tied to the table that the form is based on. So you set the source table of the form, you add a table box, and the form will display records from that table. From there, all you have to do is select fields from the field list and drop them into the table box. You don’t need to write any code to bind or populate controls, no need for any type conversion. The form is smart enough to know how to deal with data types.

Again I am going to ask you to explain what you want to do, so that we can help you understand how NAV works.

Thanks a lot to all.

@ Redrose: it might seem like we’re picking on you… I just looked back on this thread and it looks a bit intimidating.

Please, we all really want to help you, but feel that you are going about it the wrong way. If you could explain to us what you need to accomplish. Not in terms of “I want to convert an option field into a text field”, but in terms like “I need to pull in a default address from a Vendor into a Purchase Order”. Not in technical terms, but in functional terms. That way, we know what you need to do, and we can help think of a better way to get you there.