Hi
I'm using Purchase order send approval workflow. once the approval request is approved by the approver i.e status of approval entries changes to Approved. An email with purchase order details as an attachment should be sent to the Vendor.
I've written code for the email with attachment but how to trigger this code?
can someone help.
*This post is locked for comments
Hi Binesh,
Thanks for so much help!
I created another variable Rec_Purchase with record Purchase Header and saved my PDF using Record Rec_Purchase as Filename. This solution worked and I get my pdf with details pertaining to my Purchase Order number.
Hello,
Declare report Variable of Report 405
ReportVariable.SETTABLEVIEW(PurchaseHeader)
For reference see bellow:
-----------------
SalesQuotePdf(DocumentNo : Code[20];PdfDocPath : Text[250])
CLEAR(QuoteReport);
SalesHeader.RESET;
SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Quote);
SalesHeader.SETRANGE("No.",DocumentNo);
IF SalesHeader.FINDFIRST THEN BEGIN
QuoteReport.USEREQUESTPAGE(FALSE);
QuoteReport.SETTABLEVIEW(SalesHeader);
Path := 'C:\Temp\'+PdfDocPath;
QuoteReport.SAVEASPDF(Path);
DocSetup.GET;
DocSetup.TESTFIELD(Exportpath);
FromFile := Path;
ToFile := DocSetup.Exportpath + PdfDocPath;
IF FILE.EXISTS(FromFile) THEN BEGIN
MoveQuoteFile(FromFile,ToFile);
END;
IF FileMgt.ClientFileExists(Path) THEN
ERASE(Path);
END;
Note:
Hi Binesh,
I followed your code and called my function from purchase order form action for testing purpose.
still in my pdf I get record details of all purchase orders.
Hello Chris,
How you called SendEmailWithAttachment, Send your code, because you are passing the Purchase header,
and if you didn't filter correctly, then it pulled all records.
You have to filter purchase Header with particular no. or whatever you want, that's it.
Hi Binesh
Thanks for you reply. My code fetches the purchase order number and also mail is sent successfully but when I open my pdf document in the mail. I receive details of all purchase orders.
is there any means to filter and send only details of my purchase order in the pdf rather than sending all.
Hello Chris,
I Checked in my DB with Sales Header, its working, See the bellow Image.
Do one thing Debug your code, it might be chances to:
> Not getting the Purchase Order No.
> IF in your PO no records then, system won't create PDF also.
> Better to filter one PO like me that are exist and then try it.
> also check in PO no, is any special char or spaces in last.
Hi Binesh,
I'm finding the above post difficult to understand. can you please explain it again.
I need to get the purchase order number and then attach the purchase order as a pdf document.
can you tell me what modification need to be done to my code. cause my code works successful without using workflows.
Hello Chris,
Better to use FileMgmt Codeunit for copying the server file in to client.
or you can use bellow solution as per ur requirements
OR use for saving
FileName := FileMgt.ClientTempFileName('PDF');
//Bellow code are working.,
IF YourReport.SAVEASPDF(TotalFileNameL) THEN BEGIN
COMMIT;
IF FileMgt.ClientFileExists(TotalFileNameL) THEN BEGIN
SendMailTest('WIRE',MonthL,TotalFileNameL);
END ELSE
ERROR(Text012,TotalFileNameL);
END ELSE
ERROR(Text013);
//Find the screenshot for SendMail. its working
Hi
I created a workflow response for 'Purchase order send approval workflow' and added it to the workflow in the front end. I need to attach the document as .pdf file. I've written the below code but it work if I use it normally without a workflow i.e on a Action. but doesn't work with the workflow.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156