Pages

April 08, 2013

Create a From through X++ Job

Hi,
Here is small code for create a AX From through X++ Job code.

static void theaxapta_formJob(Args _args)
{
    Form                    form;
    FormRun                 formRun;
    Args                    args;
    FormBuildDesign         formBuildDesign;
    FormBuildControl        formBuildControl;
    FormBuildTabControl     formBuildTabControl;
    FormBuildTabPageControl formBuildTabPageControl;
    FormBuildGridControl    formBuildGridControl;
    FormBuildDatasource     formBuildDatasource;
    FormBuildStringControl  formString;
    ;
    form = new Form();
    formBuildDatasource     = form.addDataSource(tableStr(PurchTable)); // Main Data Source for FORM
    formBuildDesign         = form.addDesign('design');// Add design in FORM
    formBuildTabControl     = formBuildDesign.addControl(FormControlType::Tab, 'Tab');
    formBuildDesign.height(1000);
    formBuildDesign.width(1000);
    formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, 'TabPage');
    formBuildTabControl.height(500);
    formBuildTabControl.width(500);

    formBuildGridControl    = formBuildTabPageControl.addControl(FormControlType::Grid, 'Grid');
    formBuildTabPageControl.height(500);
    formBuildTabPageControl.width(100);

    formString              = formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(PurchTable, PurchId));
    formString.label("Purchase Order Form");

    args    = new Args();
    args.object(form);
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
}


-Harry

No comments:

Post a Comment

Thanks