Forms and company context

If you open form from X++ in different company you expect that it will work in the company you stated?
static void startForm(Args _args)
{
    FormRun formRun;
    Args    args;

    changeCompany('usmf')
    {
        args = new Args();
        args.name(formstr(TestForm));

        formRun = ClassFactory::formRunClassOnClient(args);
        formRun.init();
        formRun.run();
        formRun.detach();
    }
}
TestForm is simple form without datasource and only one button which displays infolog with current company:
void clicked()
{
    super();
    info(curext());
}
Bad thing is that it will not work as expected and if you change the window to the form which is in other company and then switch back and press the button to diplsay current company you surprisingly will not see usmf, instead there will be company of another form.
Other forms like CustTable will work as expected. And the problem is in datasource. All form without datasource will not work as expected.
There is property on form Design which is called SetCompany which should "Set the default company each time the form is activated", but unfortunately it does not work for forms without datasource.

 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags