Tuesday, April 6, 2021

How to call child form with filtered records using X++ in D365FO

 How to call Form with filtered records using X++ in D365FO.


check below code.

    =======================Using Form Run======================

    {

        Args            args = new Args();//(formStr(formName));

        FormRun         formRun;

        FormDataSource  formDataSource = new FormDataSource();

        ;

        args.name(formStr(formName));

        formRun = ClassFactory.formRunClass(args);

        formRun.init();

        formDataSource = formRun.dataSource();

        formRun.run();

        formDataSource.filter(fieldNum(TableName, FieldName), "Value");

        formRun.detach();

        -------------------------------------------------OR-----------------------------------------------

        Args args = new Args();

        args.caller(_caller);

        args.parm(_parm);


        FormRun fr = new MenuFunction(menuitemDisplayStr(FormName), MenuItemType::Display).create(args);

        fr.run();

        fr.dataSource().findRecord("Value");

        fr.detach();

    }


====================Using Menu Function===========================


    {

        MenuFunction            menuFunction;

        FormRun                 formRun;

        Args                    args = new Args();

        ;


        // args.record(TableBuffer);

        args.lookupRecord(TableBuffer); //Below 2 methods are also working same

        // args.lookupField(fieldNum(TableName, FieldName));

        //args.lookupValue('Value');

        menuFunction = new MenuFunction(menuitemDisplayStr(EcoResAttributeType), MenuItemType::Display);

        menuFunction.run(args);

    }


Keep Daxing!!

No comments:

Post a Comment