First we need to work on how to send normal reports to PDF.
Such That we need to create a new Class with given methods below is mandatory
Next in ReportPdf( ) we have to write logic how to save normal ax reports to pdf file.
void ReportPdf()
{
Args args;
ReportRun rr;
str reportName = "ProductionDailyReport";
str myPath;
int i;
TransDate td;
str rangeDate;
;
i = 1;
td = systemDateget();
args = new Args(reportName);
args.caller(rr);
rr = new reportRun(args);
rr.query().interactive(false);
rr.query().dataSourceTable(tablenum(ProdJournalRoute)).addRange(fieldNum(ProdJournalRoute,transDate)).value(SysQuery::value(td));
rr.report().interactive(false);
rr.setTarget(printMedium::File);
rr.printJobSettings().setTarget(PrintMedium::File);
rr.printJobSettings().preferredTarget(PrintMedium::File);
rr.printJobSettings().format(PrintFormat::PDF);
rr.printJobSettings().warnIfFileExists(false);
rr.printJobSettings().suppressScalingMessage(true);
pdfFileName = @"\\AXTESTDEV1\D$\Demo\Demo.pdf";
rr.printJobSettings().fileName(pdfFileName);
rr.init();
rr.run();
}
Next in EmailCheck( ) we have to write logic how to send the reports in email to users.
void EmailCheck()
{
//Set permissionSet2 = new Set(Types::Class);
InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
;
CodeAccessPermission::revertAssert();
permission.assert();
mailer = new SysMailer();
parameters = SysEmailParameters::find();
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress(xyz@softwarecompany.com');
mailer.tos().appendAddress('abcd@comapny.com');
//mailer.tos().appendAddress('Test@company.com');
mailer.htmlBody('Find the attachment. <Br>\n NOTE:This is a System Generated Email. Please do not Reply.');
mailer.subject('Report Attached(Testing Mail)');
mailer.attachments().add("D:\\Demo\\Demo.pdf");
mailer.sendMail();
CodeAccessPermission::revertAssert();
}
Finally We want to configure this class into batch Job User Form...!!!
Refer this Link For the Batch Job process :
Happy Dazzles..!!
No comments:
Post a Comment