Friday, 30 May 2014

,

Passing Args from Form to Class in Dynamics Ax 2012


In this post, i will demonstrate on how to pass Args from Form to Class in Dynamics Ax.



This post will helpful for those who are keen to learn about Args which is very much fruitful concept in Dynamics Ax.
The Scenario is when I select multiple grids in Form , those records will be passed to Class and once you received those records in Class and you can use it as per your Requirement.
Firstly, make one form from which you will pass the arguments and drag your table to the datasource, then drag the fields to the grid of design node, also drag one button adn override the clicked method.
write the following code in clicked method.
void clicked()
{
int recordsCount;
SampleTbl _SampleTbl;
container con;
Args args;
str multiSelectString;
;

args = new Args();
recordsCount = SampleTbl_ds.recordsMarked().lastIndex(); // gets the total records selected
_SampleTbl = SampleTbl_ds.getFirst(1);
while (_SampleTbl)
{
// storing recid of selected field in container
con = conIns(con,1,_SampleTbl.RecId);
// converting container to string with comma separated
multiSelectString = con2Str(con,’,’);
_SampleTbl = SampleTbl_ds.getNext(); // moves to next record
}
// passing string
args.parm(multiSelectString);
// calling menu item
new MenuFunction(identifierstr(SampleTest), MenuItemType::Action).run(args);

}
first
make one class and write the following code in main method of it.
public static void main(Args args)
{
SampleTbl _SampleTbl;
container con;
int i;
str multipleRecords;
;
multipleRecords = args.parm();
info(strFmt(‘%1′,multipleRecords));
// i am just here an infolog of recids but you can do as per requirement once you got multiple records
}

thanks and your feedback will be appreciated

0 comments to “ ”

Post a Comment