This post is machine-translated. The original post in german language can be found here.

Open form through code and modify query of form

The following code opens form VendTable in grid and modifies the query of the form. In the example three specific vendors should be shown.

static void openFormGridWithQuery(Args _args)
{
    Args args;
    FormRun fr;
    QueryBuildDataSource qbds;
    FormDataSource fds;
    QueryBuildRange qbr;

    args = new Args(formStr(VendTable));
    args.caller(null);

    args.menuItemType(MenuItemType::Display);
    args.menuItemName(menuitemDisplayStr(VendTable));
    args.formViewOption(FormViewOption::Grid);

    fr = classfactory.formRunClass(args);
    fr.init();
    fds = fr.dataSource();
    qbds = fds.queryBuildDataSource();

    qbds.addRange(fieldNum(VendTable, RecId)).value(queryValue(22565421239));
    qbds.addRange(fieldNum(VendTable, RecId)).value(queryValue(22565421240));
    qbds.addRange(fieldNum(VendTable, RecId)).value(queryValue(22565421714));

    fr.run();
    fr.detach();
}

The form opened by above job may look similar to the following screenshot:

Screenshot

These post applies to following version:
Dynamics AX 2012

 
 

 

 
 
 
Posts of the actual month
February 2026
MoTuWeThFrSaSu
 1
2345678
9101112131415
16171819202122
232425262728 
 
© 2006-2026 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.