Passing Parameters to Menu Item

maria_iva81
maria_iva81 Member Posts: 39
edited 2006-02-02 in Dynamics AX
How can i pass parameters(possible values from BaseEnumType) to MenuItems so that later according to the value to activate different Report....Please help

Comments

  • Mugur
    Mugur Member Posts: 93
    It looks like you are very new to Axapta.. Try reading the following topics in Ax. Developer guide:

    1. Description of properties for menu items
    2. Activating a menu item from your X++ code

    and about the Args class under AOT\System documentation\Classes.

    Good luck :D
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • maria_iva81
    maria_iva81 Member Posts: 39
    I start reading now and you are right its been only 2 weeks with Axapta :lol: If there are any problems later than i'll post them. Once again thank u :)))
  • maria_iva81
    maria_iva81 Member Posts: 39
    Soory but i'm hopeless whst i did is created 3 action MenuItems and a class which is speciafied in their Object property. In the main method of the class i wrote this:
    static void main(args a)
    {
    ReportRun runRep;
    Args args;
    EnumType enumType;
    ;

    switch(enumType)
    {
    case EnumType ::Type1 : args = new Args("ReportA");
    runRep = new reportRun(args);
    runRep.run();

    case EnumType ::Type2: args = new Args("ReportB");
    runRep = new reportRun(args);
    runRep.run();

    case EnumType ::Type3 : args = new Args("ReportC");
    runRep = new reportRun(args);
    runRep.run();

    case EnumType ::Type4 : args = new Args("ReportD");
    runRep = new reportRun(args);
    runRep.run();
    }
    }

    I'm getting an error saying that no object is specified for the action MenuItem (and it is specied ) and that there is no design specified for the report so...I'm totally lost..Please help me
  • Mugur
    Mugur Member Posts: 93
    u'r example doesn't make sense. where r u initializing the enumType so before entering the switch stmt? It will always default to the first value.

    supposing you call a class using an ActionMenuItem ...

    void callMyClassWithArgs()
    {
    args = new args();
    menufunction mf;
    ;

    args.parmEnumType(enumNum(MyEnum));
    args.parmEnum(MyEnum::MyValue);
    mf = new menufunction(MenuItemType::action,menuitemactionstr(mymenuitem));
    mf.run(args);
    }

    then in the main method of class you will do something like

    static void main(args args)
    {
    myenum myenum;
    ;

    myenum = args.parmenum();

    (do the switch and the rest of stmts...)
    }

    Please see that you can also set enum parameters to a Menuitem directly from properties.
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • maria_iva81
    maria_iva81 Member Posts: 39
    ok but where i have to place the code for that method void callMyClassWithArgs() (that you gave me as an example), i call the action menu items from MenuItemButtons...
  • Mugur
    Mugur Member Posts: 93
    I already said in that case u should put in the property of the menuitem

    OR

    overwrite the clicked() method of the menuitembutton, delete super() and place my code instead...
    Kind regards,

    Ciprian Dudau
    Axapta Developer