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
November 2025
MoTuWeThFrSaSu
 12
3456789
10111213141516
17181920212223
24252627282930
 
© 2006-2025 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.