code for a button to open a new form

smilessmiles Member Posts: 9
edited 2011-02-16 in Dynamics AX
Hi



I want to write a code for a button to open a new form.

Can you help me to find some tutorials and links to do so .



Thanks in advance .

Comments

  • aliennavaliennav Member Posts: 449
    On push of the button ..write Form.Runmodal(XX);
    "xx " is the no. (ID) of the form u want 2 open.
  • MikerMiker Member Posts: 105
    What are you all speaking about? :roll:
    There are may be some possibilites to do this!
    And first of all - use reference type!
    If you have one table linked to another, you do not need to write any line of code
    going to Europe
  • dferrarettodferraretto Member Posts: 5
    like this

    ***
    MenuItemNameDisplay menuItemName;
    MenuFunction menuFunction;
    FormRun configForm;
    Args args;
    ;

    //Get the name of the menu item in the Action table that we will use
    //to launch the form.
    menuItemName = aifEndpointActionPolicy.displayMenuItemName();

    //Create a new menu function based on the menu item name
    menuFunction = new MenuFunction(menuItemName, MenuItemType::Display);

    //create a populate the arguments that will be passed to the form
    args = new Args();
    args.caller(this);
    args.record(aifEndpointActionPolicy);

    //Create the form from the menu function
    configForm = menuFunction.create(args);
    if(configForm)
    //Run the form
    configForm.run();
    else
    //Menu item does not exist
    throw error(strfmt("@SYS55489", menuItemName));
    ***
  • jaestevanjaestevan Member Posts: 10
    the easier (but not the only) way:

    If you want to call directly to the form:
    Args            args;
    FormRun         formRun;
    ;
    
    args = new Args();
    args.name(formStr(form_name));
    
    formRun = ClassFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
    

    If you want (and you can) call to a MenuItem (recommended), do that way:
    MenuFunction    mf;
    ;
    
    mf = new MenuFunction(menuItemDisplayStr(menu_item_name), MenuItemType::Display); // Or the Type that matches
    mf.run();
    

    Hope this helps.
    [Dynamics AX developer]
    http://www.jaestevan.com (AX Dev Blog)
    http://twitter.com/jaestevan (follow me!)
  • NatalieSmith01NatalieSmith01 Member Posts: 1
    like this

    ***
    MenuItemNameDisplay menuItemName;
    MenuFunction menuFunction;
    FormRun configForm;
    Args args;
    ;

    //Get the name of the menu item in the Action table that we will use
    //to launch the form.
    menuItemName = aifEndpointActionPolicy.displayMenuItemName();

    //Create a new menu function based on the menu item name
    menuFunction = new MenuFunction(menuItemName, MenuItemType::Display);

    //create a populate the arguments that will be passed to the form
    args = new Args();
    args.caller(this);
    args.record(aifEndpointActionPolicy);

    //Create the form from the menu function
    configForm = menuFunction.create(args);
    if(configForm)
    //Run the form
    configForm.run();
    else
    //Menu item does not exist
    throw error(strfmt("@SYS55489", menuItemName));
    ***
    Thanks a lot for the coding help.
    Your sharing is much appreciated.
Sign In or Register to comment.