Question

Essentially, this is what I'm faced with:

  1. I want to modify the InventTrans form
  2. By default, it has the entire InventTrans datasource set to AllowEdit = No
  3. I want to enable editing on ONE new Enum field (NoYes type)

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!

Was it helpful?

Solution

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);
    }
}

OTHER TIPS

I have a scenario in which I want to allow editing of ItemID in the InventJournalTrans form, based on an enum value in ANOTHER form. Is this possible?

Can args() class(parm method) be used to fetch the value of the checkbox? along with on the below condition in the active()?
My codes:

public int active()
{
int ret;
;

ret = super();

if([datasource table name].[Column 1 field name] == [Column1 value to
deactivate Column 3])
{
[datasource table name]_ds.object(fieldNum([datasource table name],
[Column 1 field name])).allowEdit(false);
}
else
{
[datasource table name]_ds.object(fieldNum([datasource table name],
[Column 1 field name])).allowEdit(true);
}

return ret;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top