Sunday, 8 February 2015

Dynamics AX form requires an active buffer

At the start of my Dynamics AX development learning, I received the error "Dynamics AX form requires an active buffer" many times whenever I tried to open a second level of form (child form). The reason is that I was not submitting the required parameter values for it.

To open second level of form, you have to mention the name of the caller form (parent form). The best example is Production Order's Picking List form. To open the "Production Journal Lines" sub-form within Picking List form, first create the Picking List form instance and open it, next create the "Production Journal Lines" form instance and set the "Caller" property with Picking List form instance.

Here is the code for above explanation: -

        Args                    argsForm;
        FormRun             formRun;
        FormRun             subformRun;
        ;
     

        //Open Picking List form
        argsForm = new Args(formstr(ProdJournalTable));
        argsForm.record(ProdJournalTable::find(prodJournalTable.JournalId));
        formRun = classFactory.formRunClass(argsForm);
        formRun.init();
        formRun.run();


        //Now open sub-form (Production Journal Lines)
        argsForm = new Args(formstr(ProdJournalTransBOM));
        //Here you can mention the parent form instance as an active buffer
        argsForm.caller(formRun);      
        argsForm.record(ProdJournalTable::find(prodJournalTable.JournalId));

        subformRun = classFactory.formRunClass(argsForm);
        subformRun.init();
        subformRun.run();
        formRun.close(); //Now close the parent form.
        subformRun.wait(); //This halts your programme execution.

As you can see in the above mentioned highlighted code line, "formRun" is the parent form's instance, which you can use in the sub-form as an active buffer.

No comments:

Post a Comment