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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s