Display Data in Report based on MenuItem

Hi,

I have to create 1 report and 3 Menuitems. My task is I have to display ItemA when I open MenuItemA and same for itemB and C when I opened MenuitemB and C resp. Please tell me wht I have to do.

Probably the best approach is to create an enum and set different enum values on each menu item. Then take the value from Args and process as you need.

ya. I have enum field which is having value A,B,C, None and for that I have MenuItem A,B,C. If I open MenuItem A then it should open the report which is having A record only. then where I need to write the code??

You have to place the code in the init method of the report you have to retrieve args.parmenum() value and write appropriate code

also refer http://msdn.microsoft.com/en-us/library/aa853493(v=ax.10).aspx

Hi Martin, I have set the MenuItemA property of EnumTypeParamter to ENUM Field and EnumParameter property to ENUM Value. Then After that Wht I need to do please tell me?

Hi Narayan, I have written some code just check it below.

public void init()
{
super();

if (element.args().ParmEnumType())
{
switch (Element.Args().ParmEnum())
{
case (ABC::A) :
{
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::A;
break;
}
case (ABC::B) :
{
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::B;
break;
}
case (ABC::C) :
{
// element.ToggleCommission(false);
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::C;
break;
}

default :
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::None;
break;
}
}

}

But I have doubt when i will open MenuItem A then will it display record of ItemA???

If you’re able to get the enum value (see the link in narayan’s post), you just need to use it to implement your business logic, i.e. to add a range to the query (element.query()).

Hi Martin…

check the below code.

public void init()
{
super();

query = new Query();
qbds = query.addDataSource(tableNum(InventTable));
qbr = qbds.addRange(fieldNum(InventTable,ABCValue));
qbr.value("");

if (element.args().ParmEnumType())
{
switch (Element.Args().ParmEnum())
{
case (ABC::A) :
{
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::A;
break;
}
case (ABC::B) :
{
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::B;
break;
}
case (ABC::C) :
{
// element.ToggleCommission(false);
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::C;
break;
}

default :
select itemid,itemName
from inventTable join inventTableModule
where inventTable.ABCValue == ABC::None;
break;
}
}

}

Yo hav to either write a while select query and use send() method on the report to display the record or use Query framework …Acquaint Yourself with basic things regarding Query framework and report methods

Define your datasources and the range in AOT (under the report’s Data Sources node). Then, implement init() as follows:

super();
if (element.args().parmEnumType() == enumNum(ABC))
{
    element.query().dataSourceTable(tableNum(InventTable))
        .findRange(fieldNum(InventTable, ABCValue))
            .value(queryValue(element.args().parmEnum()));
}

It takes the automatically generated query (element.query()), finds the datasource for InvenTable, finds the range for ABCValue and set the value from args().parmEnum(). It also ensures that the type of parameter is what you expects.

Hey Thanx Martin and Narayan for your help. Actually I am new to AX and just before 1 week I have joined the company…So I dont know that much functionality and I am exploring AX functionality…