add Option string at run time

redroseredrose Member Posts: 36
edited 2009-08-01 in Navision Attain
Dear all,

I want to add Option string at runtime. I tried to assign a new optionstring value to one of my option field.But system is showing error that 'its not an option'. How can i add option string values like 0,1,2,3 at runtime.

Comments

  • bbrownbbrown Member Posts: 3,268
    You cannot.

    What are you trying to accomplish? Maybe we can suggest a different approach.
    There are no bugs - only undocumented features.
  • garakgarak Member Posts: 3,263
    you can't. The options you must define before in the design mode.
    What are you trying to do?

    If you're options are "dynamically", why do you not use a codefield with an tablerealtion to a new table where you define the "options" like:
    Table A with Code (Code 10) and Description (Text 30) and your new field in Table B has a relation to the Code field of table A.

    Regards
    Do you make it right, it works too!
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    You cannot add new options during runtime but you can simulate removing existing on the form .

    You need to define two textboxes with SourceExpr pointing to the same variable or table field, name the two TextBoxes using two different names (TextBox1 and TextBox2 for example), and in each of text box change OptionCaption by removing unnecessary options but leaving commas.

    Like this:
    OptionString in Option Field in the table or option variable: 0,1,2,3,4,5
    OptionCaption in TextBox1: 0,1,,3,,5 - the user will see in dropdown only option 0,1,3,5
    OptionCaption in TextBox2: ",,2,,4,5" - the user will see in dropdown only option 2,4,5

    Then you can use VISIBLE property of the TextBoxes to hide/show correct texbox on the form using
    CURRFORM.TextBox1.VISIBLE(b);
    CURRFORM.TextBox2.VISIBLE(NOT b);

    where b is Boolean variable or expression

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.