Print selected records from a checkbox control in form design in AX.

Hi,
To print report from the selected records as shown below..
When i clicked on menu item button then selected records should be print on report. i.e. id 001 & 002..

6663.my

To print the selected data in the report, there are many ways:
I achieved the data into the report through below 2 methods..

Method 1:

create a new table…(Duplicate the table which contains the above records..)
write below code in menuitembutton clicked() method.. before super() so that data gets inserted before printing the report..

void clicked()
{
Student inventLocal;
;
//getFirst method gets all the selected records in the grid
inventLocal = Student_ds.getFirst(true);
while (inventLocal)
{
info(strfmt(“You selected Item %1”,inventLocal.Studentid));
//insert the record into temporary table…
// get the next selected record
inventLocal = Student_ds.getNext();
}
super();
}

Use the newly created table in the report..
delete all the records from the newly created table, whenever you click the menuitembutton..

Method 2:

use containers ..
void clicked()
{
Student inventLocal;
container c;
int i;
;
//getFirst method gets all the selected records in the grid
inventLocal = Student_ds.getFirst(true);
while (inventLocal)
{
i++;
info(strfmt(“You selected Item %1”,inventLocal.Studentid));
c = conins(c,i, inventLocal.recid);
// get the next selected record
inventLocal = Student_ds.getNext();
}
super();
}

after inserting the recids.. fetch the container values from container in the fetch method in report..
to pass the container values from menuitembutton clicked() method to report fetch() method convert container to string.. and then use args.parm(); to pass the arguments..
use element.args().parm(); to fetch the values which are passed in the menuitembutton clicked() method.
For the help of any functions in AX, go through this link:

http://msdn.microsoft.com/en-us/library/aa856741.aspx

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s