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.
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.
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);
Comments
What are you trying to accomplish? Maybe we can suggest a different approach.
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
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
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03