Thursday, 5 February 2015

Enabling and disabling fields based on enum type in AX 2012


Example you have transaction type Enum in SMAServiceOrderLine table,
then you have a requirement to enable some fields in SMAServiceOrderLine_W only when smatransaction type = hours else disabled.

Then goto datasource methods and override active method and write the following code :

public int active()
{
    int ret;

    ret = super();

    if(smaserviceorderline.transactiontype != smatransactiontype::hour)
    {
        smaserviceorderline_w_ds.allowedit(false);
    }
    else
    {
         smaserviceorderline_w_ds.allowedit(true);
    }

    return ret;
}

No comments:

Post a Comment