27 October 2010

pass the parameter to report in Dynamics AX

1. Calling menuItem. Task
This is in Report to get selected record parameter like sales id ,this code is making the defalut range value the selected record of S.O -> salesId. this will pront the selected record only on report
Here we are controlling the query range prompt.

Sales Tabel form -> MenuItembutton clicked()- properties remove the menuItemName:

void clicked()
{
Args args = new Args();
MenuFunction menuFunction;
;
args.parm(SalesTable.SalesId);
menuFunction = new MenuFunction(menuitemoutputstr(Report9), MenuItemType::Output);// Report9 is menuItem
menuFunction.run(args);
super();
}
--------
In Report-> init()

public void init()
{
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable,SalesId)).value(element.args().parm());
salesId = element.args().parm();
this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}
catch(exception::Error)
{
info("Errosr in init");
}
}
-----------------------------------------------
2.calling report
form->Button
void clicked()
{

Args args = new args();
ReportRun reportRun;
;

args.parm(PurchReqTable.PurchReqId);

args.name(reportstr(PurchRequisitionDetails));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportrun.run();
//hello

super();
}
Report and click on ‘Override Method –> init’

In this init method, you need to enter the following code to allow the report to read the parameters from the form.

public void init()
{
;
try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(PurchReqTable))
.addRange(fieldnum(PurchReqTable, PurchReqId)).value(element.args().parm());

this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}

catch(exception::Error)
{
info(“Error in init method”);
}

}

No comments:

Post a Comment

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...