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

Open form through code

Below you find some examples, how to open a form through code. Each example has it's own Advantages and disadvantages, but i think there is an example available for the most Scenarios.

static void openFormThroughCode_0(Args _args)
{
    menuFunction menuFunction;
    args args;
    CustTable custTable = CustTable::find('1101');
   
    args = new args();
    args.record(CustTable);
    args.formViewOption(FormViewOption::Grid);
   
    menuFunction::runClient(identifierStr(custTable), MenuItemType::Display, false, args);
}

 

static void openFormThroughCode_I(Args _args)
{
    FormRun formRun;
    args args = new args();
    args.name(formstr(CustTable));
    args.formViewOption(FormViewOption::Grid);
   
    formRun = classFactory.formRunClass(args);
    formRun.run();
    formRun.wait();
}

 

static void openFormThroughCode_II(Args _args)
{
    FormRun formRun;
    args args = new args();
    CustTable custTable = custTable::find('250000');
    args.name(formstr(CustTable));
    args.formViewOption(FormViewOption::Grid);
   
    args.record(custTable);
   
    formRun = classFactory.formRunClass(args);
    formRun.run();
    formRun.wait();
}

 

static void openFormThroughCode_III(Args _args)
{
    SysInfoAction_Formrun SysInfoAction_Formrun;
   
    SysInfoAction_Formrun = SysInfoAction_Formrun::newFormname(formStr(CustTable));
    SysInfoAction_Formrun.run();
}

 

static void openFormThroughCode_IV(Args _args)
{
    SysInfoAction_Formrun SysInfoAction_Formrun;
    CustTable custTable = custTable::find('250000');
   
    SysInfoAction_Formrun = SysInfoAction_Formrun::newFormname(formStr(CustTable));
    SysInfoAction_Formrun.parmCallerBuffer(custTable);
    SysInfoAction_Formrun.run();
}

 

static void openFormThroughCode_V(Args _args)
{
    SysInfoAction_FormrunQuery SysInfoAction_FormrunQuery;
    Query query;
   
    query = new query();
    query.addDataSource(tableNum(CustGroup));
   
    SysQuery::findOrCreateRange(    query.dataSourceTable(tableNum(CustGroup)),
                                    fieldNum(CustGroup, CustGroup)).value('D-INL');
   
    SysInfoAction_FormrunQuery = SysInfoAction_FormrunQuery::newFormnameQuery(formStr(CustGroup), query);
    SysInfoAction_FormrunQuery.run();
}

 

static void openFormThroughCode_VI(Args _args)
{
    SysInfoAction_Formrun SysInfoAction_Formrun;
    CustTable custTable = custTable::find('250000');
   
    SysInfoAction_Formrun = SysInfoAction_Formrun::newFormname(formStr(CustTable));
    SysInfoAction_Formrun.parmCallerBuffer(custTable);
    SysInfoAction_Formrun.parmControlname(identifierStr(GridGroup)); // Trick, um im der Rasteransicht zu starten. Das Control GridGroup ist ein Element, in dieser Ansicht
    SysInfoAction_Formrun.run();
}

 

static void openFormThroughCode_VII(Args _args)
{
    SysInfoAction_MenuFunction SysInfoAction_MenuFunction;
   
    SysInfoAction_MenuFunction = SysInfoAction_MenuFunction::newMenuItem(menuItemDisplayStr(CustTable), MenuItemType::Display);
    SysInfoAction_MenuFunction.run();
}

 

static void openFormThroughCode_VIII(Args _args)
{
    SysInfoAction_MenuFunction SysInfoAction_MenuFunction;
    CustTable custTable = custTable::find('250000');
   
    SysInfoAction_MenuFunction = SysInfoAction_MenuFunction::newMenuItem(menuItemDisplayStr(CustTable), MenuItemType::Display);
    SysInfoAction_MenuFunction.parmCallerBuffer(custTable);
    SysInfoAction_MenuFunction.run();
}

 

These post applies to following versions:
Dynamics AX 2009, Dynamics AX 2012

Add comment
 
 

 

 
 
 
Posts of the actual month
Mai 2024
MoTuWeThFrSaSu
 12345
6789101112
13141516171819
20212223242526
2728293031 
 
© 2006-2024 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.