Monday, March 14, 2011

Display Page Footer only in the last page of the report in AX 2009

Hi Folks,

I have seen that most of the developers face the problem in displaying the Page footer only in the last page of the report. Epilog is printed just after the page footer on the last page in a report. So, this is printed in a separate page. But to print in the last page footer, the process is as follows:

  1. Declare a boolean variable(boolean printPageFooter) in the class declaration.
  2. In the fetch method, before looping the query make the boolean variable false and after running the complete query make the boolean variable to true.printPageFooter = false;
while (queryrun.next())
{

}
printPageFooter = true;
ret true;


Now override the executeMethod of the Page footer in which this section is executed only if the boolean variable is set to true.

Thats it................The problem is solved.

Wednesday, March 9, 2011

How to populate an Outlook Client by Creating a Mail Item, Attach a Report, and Send the Mail through AX 2009

Hi Folks,

In AX, using SysMailer class we can compose a mail and send it through code in AX but if we would like to populate the outlook client by creating a mail item then attaching a report and also attaching the sender's email address as well as subject to it then here is the code snippet for it:

#SysOutLookCOMDEF
#define.outlook("Outlook.Application")
#define.mapi("MAPI")
COM sysOutlook;
COM sysOutlookNameSpace;
COM sysOutlookMailItem;
COM sysOutlookAttachment;
COM sysOutlookRecipient;
;

sysOutlook = new COM(#outlook);
sysOutlookNameSpace = sysOutlook.getNamespace(#mapi);
sysOutlookNameSpace.logon();
sysOutlookMailItem = sysOutlook.CreateItem('Outlook.OlItemType.olMailItem');
sysOutlookMailItem.To("test@test.com");
sysOutlookMailItem.Subject("Hi-Test");
sysOutlookAttachment = sysOutlookMailItem.Attachments();
sysOutlookAttachment.Add(@"C:\New.pdf",1,1,"New");
sysOutlookMailItem.save();
sysOutlookMailItem.display();

info("The action is created in Microsoft Outlook");
sysOutlookNameSpace.logoff();

So, if you would like to send it and instead of display() method, just use the Send() method in sysOutlookMailItem class above.