Now, I add menu item button on ReqTransPo(form) to print ReqTransOverview(report) for set the selected itemID as default.
I try to use
this.args().record().recid
to get the recid for reqPO(datasource), but it retrun the recid is the first record of InventTable(datasource).
How can I pass reqPO.itemid to report?
Thanks!
Have you set the dataSource property for the menu item correctly? What is the version of AX?
for reference see,
\Classes\InventTransferOrdOverviewController\setRanges (in AX 2012)
\Reports\InventTransferOrderOverview\Methods\initFromCaller (in AX 2009)
Hi Kranthi
my version is AX 4.0
how to set the datasource property for the menu item in AX 4.0?
Thanks
bongcs
November 7, 2013, 7:37am
4
Hi,
I dont really understand your question, but from my knowing is each form or report can assign its particular data source. For example when you expand a report in your AOT
Sample.xpo
-Methods
-Query (Data Sources)
-Designs
You can add a new data source by going to data source tab, right click, click new data source, right click on the new data source and assign a table (table comes from server management studio) with it.
Hi Bong
Thanks you for the reply.
I had tried to add both datasource (InventTable & reqPO) on report (ReqTransoverview). But it is fail to return the selected itemid.
the menu item added(MenuItemButton) in the form will have the data source property.
see the implementation of \Reports\InventTransferOrderOverview
\Forms\InventTransferOrders\Designs\Design[Group:GroupTable][ButtonGroup:ButtonGroupTable][MenuButton:PrintMenu]\MenuItemButton:InventTransferOrderOverview
bongcs
November 7, 2013, 8:51am
7
Hi,
Im not sure about this but you can try go:
Respective Table
Expand Table
Data source node
Right click for properties
Find for Start Position
Select First in Start Position
Good Luck,
Regards,
Bongcs
bongcs
November 8, 2013, 1:49am
9
I think is the similar way of changing values to the screen shot below, can try ?
Now, I figured out a sligtly different solution
On the Button Clicked method:
void clicked()
{
Args args = new args();
ReportRun reportRun;
;
args.parm(ReqPO.ItemId);
args.name(reportstr(ReqTransOverview));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
//reportrun.run ();
super();
}
And then on the init method on the report;
public void init()
{
Query queryBuild = this.query();
QueryBuildDataSource qbds;
QueryBuildRange qbr;
ItemId pitemid;
;
callerInventDimId = ‘’;
reqSorting = ReqSorting::ReqDate;
super();
if(element.args().parm())
{
pitemid = element.args().parm();
qbds = queryBuild.dataSourceTable(tablenum(InventTable));
qbr = SysQuery::findOrCreateRange(qbds, fieldnum(InventTable, ItemId));
qbr.value(queryValue(pitemid));
}
else
{
qbds = queryBuild.dataSourceTable(tablenum(InventTable));
qbr = SysQuery::findOrCreateRange(qbds, fieldnum(InventTable, ItemId));
qbr.value(queryValue(pitemid));
}
}
I found that it called the init for twice. It is success to pass paramater at the first time. But, it is no paramater at the second time.
Anyone can help me? Thanks.
Yeah! I found out the solution:
Pass the parameter on menuitem, not on report.
void clicked()
{
MenuFunction mf;
args args = new Args();
;
args.parm(ReqPO.ItemId);
mf = new menufunction(identifierstr(ARN_PrintRequirementProfile), MenuItemType::Output);
mf.run(args);
}