AX 2009: Save the report in different format
In AX 2009,
whenever a user runs a report, by default first it prints to screen.
But sometimes,
you want a report to go straight to the printer or save it in some format, without a user intervention. So in such case you need to develop the logic.
But again if you want to have a report printed on screen, need to change the
logic. So to avoid that you can write your logic in such a way that whenever you
open a report, it prompts you whether report should be saved in Excel or not.
If you click
on say “Yes” then it asks you for the save path and if you click on “No” then
it prints on screen.
Inorder to
design this functionality we can add the logic in fetch method of the report. Say,
public
boolean fetch()
{
boolean ret;
dialog
d = new dialog("Select
file");
dialogField df;
;
if (box::yesNo("Do you want to save it
in Excel?", dialogbutton::Yes, "Save in Excel") ==
dialogbutton::Yes)
{
df = d.addField(typeid(FileNameSave),
"Select file to save");
if (d.run())
{
element.printJobSettings().setTarget(Printmedium::File);
element.printJobSettings().format(Printformat::ASCII);
element.printJobSettings().fileName(df.value());
}
}
else
{
element.printJobSettings().setTarget(Printmedium::Screen);
}
ret =
super();
return ret;
}
Keep reading!!!!
Happy Daxing J
Leave a Comment