Showing posts with label AX2012. Show all posts
Showing posts with label AX2012. Show all posts

Thursday, 5 February 2015

Passing values from one form to other using args AX 2012


You have two fields in a form and on click of OK button new form should open and values should be passed to new form.

add this code in the OK clicked method :

    FormRun formRun;
    container con;
    str strcon;

    Args args = new Args();

    con =    [SMAServiceOrderLine_W_StartDate.valueStr(),SMAServiceOrderLine_W_EndDate.valueStr()];
    strcon = con2Str(con);
    args.parm(strcon);

    args.name(formstr(NEWFORMNAME));

    formRun = ClassFactory.formRunClass(args);
    formRun.init();

    formRun.run();
    formRun.wait();


The values entered in this form can be retrieved in other form using container. Start date and end date are the two values that are passed from this form

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