Monday, December 6, 2010

Enable/Disable table field on form by code

FormDataSource_ds.object(fieldNum(TableName,Field)).allowEdit(false);

or for arrays

FormDataSource_ds.object((new
SysdictField(tableNum(TableName),fieldNum(TableName,FieldName),1).id())).allowEdit(false);

where 1 is the number of the field in the array.

Yes, you can go to the table and set AllowEdit Yes/No
Yes, you can also go to the form and set the field to Enabled Yes/No
Yes, you can also go to the particular field control and set Enabled to Yes/No

so why would you use this method?

1. If multiple controls are using this field and you want to disable
all instances of the field, but you dont want to disable it on the
table level
2. If the field is part of an array EDT, like Dimension, and you just
want to disable one field, not the others