PO confirmation report has to be sent mail once gets confirmed.
Default standard Ax will print the report using PurchPurchOrderJournalPrint,
to mail the report, the code has to written in the PurchPurchOrderJournalPrint,doPrint() method
as below
/// <summary>
/// Prints the document.
/// </summary>
protected void doPrint()
{
this.printConfirmReport();
this.sendmail(vendPurchOrderJour);
vendPurchOrderJour.printJournal(this, journalList);
}
private void printConfirmReport()
{
Args parameters = new Args();
SRSPrintDestinationSettings printSettings;
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract contract = new PurchPurchaseOrderContract();
FILENAME filename;
boolean newLine;
Name filenamepath;
;
newLine = journalList.first(vendPurchOrderJour);
parameters.caller(this);
if (journalList)
{
parameters.object(journalList);
}
controller.parmReportName(ssrsReportStr(PurchPurchaseOrder, Report));
contract.parmRecordId(vendPurchOrderJour.RecId);
contract.parmDocumentTitle("@SYS25545");
controller.parmReportContract().parmRdpContract(contract);
controller.parmShowDialog(false);
printSettings = controller.parmReportContract().parmPrintSettings();
printSettings.printMediumType(SRSPrintMediumType::File);
printSettings.fileFormat(SRSReportFileFormat::PDF);
printSettings.overwriteFile(true);
filenamepath = PurchParameters::find().PurchConfirmationFilepath;
filename = filenamepath + curext() + '_' +vendPurchOrderJour.PurchOrderDocNum + '.PDF';
printSettings.fileName(filename);
controller.parmArgs(parameters);
controller.startOperation();
}
private void IMX_sendmail(VendPurchOrderJour _vendPurchOrderJour)
{
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
FilePath filePath;
HcmWorker hcmWorker;
PurchTable purchTable;
Name filename;
;
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);
}
filename = PurchParameters::find().PurchConfirmationFilepath;
purchTable = PurchTable::find(_vendPurchOrderJour.PurchId);
hcmWorker = HcmWorker::find(purchTable.Requester);
mailer.subject(_vendPurchOrderJour.PurchId);
mailer.fromAddress(DirPartyTable::findByName(UserInfoHelp::userName(curUserId())).primaryEmail());
mailer.htmlBody('Purchase Order confirmation of ' + _vendPurchOrderJour.PurchId +'.' + 'Please Find the Attachment.');
mailer.tos().appendAddress(hcmWorker.email());
mailer.tos().appendAddress(VendTable::find(purchTable.OrderAccount).email());
filePath = filename + curext() + '_' +vendPurchOrderJour.PurchOrderDocNum + '.PDF';
mailer.attachments().add(filePath);
mailer.sendMail();
CodeAccessPermission::revertAssert();
}
Correct me if am wrong....
Default standard Ax will print the report using PurchPurchOrderJournalPrint,
to mail the report, the code has to written in the PurchPurchOrderJournalPrint,doPrint() method
as below
/// <summary>
/// Prints the document.
/// </summary>
protected void doPrint()
{
this.printConfirmReport();
this.sendmail(vendPurchOrderJour);
vendPurchOrderJour.printJournal(this, journalList);
}
private void printConfirmReport()
{
Args parameters = new Args();
SRSPrintDestinationSettings printSettings;
SrsReportRunController controller = new SrsReportRunController();
PurchPurchaseOrderContract contract = new PurchPurchaseOrderContract();
FILENAME filename;
boolean newLine;
Name filenamepath;
;
newLine = journalList.first(vendPurchOrderJour);
parameters.caller(this);
if (journalList)
{
parameters.object(journalList);
}
controller.parmReportName(ssrsReportStr(PurchPurchaseOrder, Report));
contract.parmRecordId(vendPurchOrderJour.RecId);
contract.parmDocumentTitle("@SYS25545");
controller.parmReportContract().parmRdpContract(contract);
controller.parmShowDialog(false);
printSettings = controller.parmReportContract().parmPrintSettings();
printSettings.printMediumType(SRSPrintMediumType::File);
printSettings.fileFormat(SRSReportFileFormat::PDF);
printSettings.overwriteFile(true);
filenamepath = PurchParameters::find().PurchConfirmationFilepath;
filename = filenamepath + curext() + '_' +vendPurchOrderJour.PurchOrderDocNum + '.PDF';
printSettings.fileName(filename);
controller.parmArgs(parameters);
controller.startOperation();
}
private void IMX_sendmail(VendPurchOrderJour _vendPurchOrderJour)
{
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
FilePath filePath;
HcmWorker hcmWorker;
PurchTable purchTable;
Name filename;
;
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);
}
filename = PurchParameters::find().PurchConfirmationFilepath;
purchTable = PurchTable::find(_vendPurchOrderJour.PurchId);
hcmWorker = HcmWorker::find(purchTable.Requester);
mailer.subject(_vendPurchOrderJour.PurchId);
mailer.fromAddress(DirPartyTable::findByName(UserInfoHelp::userName(curUserId())).primaryEmail());
mailer.htmlBody('Purchase Order confirmation of ' + _vendPurchOrderJour.PurchId +'.' + 'Please Find the Attachment.');
mailer.tos().appendAddress(hcmWorker.email());
mailer.tos().appendAddress(VendTable::find(purchTable.OrderAccount).email());
filePath = filename + curext() + '_' +vendPurchOrderJour.PurchOrderDocNum + '.PDF';
mailer.attachments().add(filePath);
mailer.sendMail();
CodeAccessPermission::revertAssert();
}
Correct me if am wrong....
No comments:
Post a Comment