AX / D365FO – Form Field allow edit based on conditon

If you want to allow edit only some fields on the form grid control this is an example that shows hot to reach this goal.

1. Create a Form method as below

public void setFieldAccess()
{
   if(XXXX == YYY)
   {
      FrmDataSource_ds.object(fieldNum(FrmDataSource,LineNum)).allowEdit(false);
   
      FrmDataSource_ds.object(fieldNum(FrmDataSource,Field2)).allowEdit(false);
    }
}

2. Call the above method from the form Data source Active method after Super() as below

public int active()
{
    int ret;

    ret = super();
    element.setFieldAccess();

    return ret;
}

Leave a comment