Enabled method

This question is answered

I would like to know if i set a field 'enable' to no, but i wanted to set back the 'enable' to yes with some certain condition inside a simple screen.

For example, when the user choose an item type to "A", the checkbox will be enable or else disable.

How should i write the method? please guide me. thank you.

Verified Answer
  • You can obtain a reference to the datasource field and use its enabled() method, e.g. YourDataSource_ds.object(fieldNum(YourTable, YourField)).enabled(true);.

    Nevertheless if you actually wanted to set AllowEdit to No on table-field level, you wouldn't be able to re-enable it in a form.

    Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

All Replies
  • Hi,

    The simplest way to do this is overriding active() on the form data source like this:

    public int active()

    {

       int ret;

       ret = super();

       Table_ds.object(fieldNum(Table, Field)).enabled(Table.ItemType == "A");

       return ret;

    }

    Notice that this will run only when you save or select the record on the form.

    Regards,

    Leandro H.

  • You can obtain a reference to the datasource field and use its enabled() method, e.g. YourDataSource_ds.object(fieldNum(YourTable, YourField)).enabled(true);.

    Nevertheless if you actually wanted to set AllowEdit to No on table-field level, you wouldn't be able to re-enable it in a form.

    Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

  • Thanks Martin, it solves my problem.