How to enable and disable textbox once you already choose in dropbox

Hi All,

I have a question on how to make enable and disable the textbox once we already choose the dropbox.

For example, If i choose the Urgent in dropbox, the text box of Details will be enabled

and if i choose the Standard in dropbox, the text box of Details wil be disabled.

I am using the Microsoft Dynamics AX 2012 as my platform…Please help me…

Are the form controls bound to a datasource?

Yes

Hi Kevin,

Set the auto declaration property to textbox of ‘details’ to ‘yes’.

Add the condition basing on the dropbox value i.e. for example

if( dropbox value == Urgent ) details.enable(false)

else if ( dropbox value == standard ) details.enable(true).

Make the conditions basing on the dropbox values, it is just an example mentioned.

You need two steps:

  1. Find the object representing the datasource field.
  2. Set properties as appropriate

Example:

// Let's say you have a DatailLevel enum
boolean enabled = myTable.DetailLevel == DetailLevel::Detail;

myTable_ds.object(fieldNum(MyTable, MyField)).allowEdit(enabled);
myTable_ds.object(fieldNum(MyTable, MyField)).skip(!enabled);

Changing individual controls is usually wrong. If the fields was displayed on another place, such as in some other tab (and don’t forget that users achieve by personalization), the other controls would be still editable. If we change properties at datasource-level, it will apply to all controls bound to the field.

Thanks Martin. I will try to use the code as example to implement my form.

and thanks to Naresh for second option.