Should I use option or code in table data type?

infonoteinfonote Member Posts: 233
Hi,

I am creating a new table and form which automatically selects a reportID depending on type e.g. A and B.
So if user choose A, report id 1 is automatically selected and if uses chooses B, report id field is automatically populated with 2.

The question is the following:
Should I use option or code data type?

Option seems to be the better option. However Code is more customizable.

Should I use option or code?

Thanks in advance. (Hope I explained well).

Comments

  • satraja2004satraja2004 Member Posts: 45
    Hi,

    I think Option data type will be the most preferable one.
    Thanks & Regards

    Raja.B
  • kinekine Member Posts: 12,562
    Answer is easy: if each value of the field have some own "meaning" for the system, e.g. that when there is A, system will work in this way and in another when there is B, than you need option. If the field have no meaning t the system and is only used to make difference between values and e.g. group the record etc., you need Code.

    Why? Because when you enter something into code field, there is no information behind for the system itself, unless you add some meaning by some setup table like "Code for Cars: CAR, Code for Bus:BUS". Without that system do not know what does it mean CAR and what does it mean BUS. Options have the meaning by design (they are numbered, with fixed values).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matttraxmatttrax Member Posts: 2,309
    I always prefer to do it with a code field and a form to allow the user/customer to change. This way they can map reports to a code without developer assistance.
  • kinekine Member Posts: 12,562
    Yes, if you have some setup which tells you which report will be started for A, and for B etc... it is ok, you are giving the meaning through the setup table... if it is only in code in a form "when the code is A, runt report xxxx and when it is B run yyyy" it is bad way. ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,304
    If the options are set and will never change, then an option field is appropriate. If you foresee the possibility that additional options might be added, and they will be different for difference situations, you need to define the requirements and normalize the data a little bit.

    You need a code/field/variable/value that determines what report to run. This could be stored in a new table with a field for the code (which would be the primary key), maybe a description, and a field for report ID (linking to the Object table, filtered on report objects). This new table could then be linked to in another table, and you run the report defined in the new table.

    Without specifying the requirement though, we can only guess at what is the best solution. Until we know the requirement it's just a stab in the dark for us. This sounds a lot like report selections by the way.
Sign In or Register to comment.