Essentially, this is what I'm faced with:
Should I set the InventTrans datasource to AllowEdit = Yes and then painfully change 40+ fields in the datasource to be AllowEdit = No, OR is there a way to programmatically iterate through the fields of the datasource and set this property by name? (Please say there is, or an equally easy way to do this!)
Thanks in advance!
This is how I would try to disable editing to all fields:
DictTable dictTable;
DictField dictField;
int fldCnt;
;
dictTable = new DictTable(tablenum(InventTrans));
for (fldCnt = 1; fldCnt <= dictTable.fieldCnt() ; fldCnt++)
{
dictField = new DictField(tablenum(InventTrans), dictTable.fieldCnt2Id(fldCnt));
info(strfmt("%1", dictField.id(),dictField.name()));
InventTrans_DS.object(dictField.id()).allowEdit(false);
}
EDIT: Better approach to iterate through form's DS'es fields only:
DictTable dictTable;
DictField dictField;
int fldCnt;
QueryBuildFieldList qBFL;
;
qBFL = InventTrans_DS.query().dataSourceTable(tablenum(InventTrans)).fields();
for (fldCnt = 1; fldCnt <= qBFL.fieldCount() ; fldCnt++)
{
dictField = new DictField(tablenum(InventTrans), qBFL.field(fldCnt));
info(strfmt("%1 %2 ", dictField.id(),dictField.name()));
if(InventTrans_DS.object(qBFL.field(fldCnt))) //exception recVersion for example
{
InventTrans_DS.object(qBFL.field(fldCnt)).allowEdit(false);
}
}