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()
dialog d = new dialog("Select file");
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");
ret = super();
Keep reading!!!! Happy Daxing J