
Occasionally we will need to change the accessibility of a certain controls/fields on a form in Dynamics AX. This can either be to hide/disable or show/enable the field from the user based on the current record they are on.
- Set the target form control’s ‘AutoDeclaration’ property to ‘yes’. by default it should be false
- Override the datasource’s active() method like shown below
[ExtensionOf(formdatasourceStr(SalesTable, SalesTable)) ]
final class SalesTable_SalesTable_DLXFormDS_Extension
{
public int active()
{
int ret = next active();
CustParameters custParm = CustParameters::find(false);
if(custParm.OTS_EnableAutoBlockSalesOrder)
{
SalesTable salesTableLcl = this.cursor();
if(salesTableLcl.M_SOMDateStatus == M_SOMDateStatusId::M_SOMConfirmed)
{
this.allowEdit(false);
}
}
return ret;
}
}
Leave a comment