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
// calling menu item
new MenuFunction(identifierstr(SampleTest), MenuItemType::Action).run(args);


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();
// 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


One response

  1. Thanks man..

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: