I am trying to save PDF's to a directory before I email them. The code is in a codeunit called from a Page. Multiple PDF's get created in the directory with the Invoice Number in the Name. The issue is that when I open the PDF's they are all for the same invoice (SPI000000).
SalesInvHeader.RESET;
SalesInvHeader.SETRANGE(SalesInvHeader."Bill-to Customer No.",'549200');
IF SalesInvHeader.FINDSET THEN
REPEAT
Name := STRSUBSTNO('SalesInvoice_%1.pdf', SalesInvHeader."No.");
ToFile := '\\pegasus\ftproot$\Invoices\' + Name; // cifs delegation to service tier for pegasus
CLEAR(SalesInvHeader2);
SalesInvHeader2.GET(SalesInvHeader."No.");
REPORT.SAVEASPDF(REPORT::"WL Sales Invoice",ToFile,SalesInvHeader2);
UNTIL SalesInvHeader.NEXT = 0;
Directory of \\pegasus\ftproot$\Invoices after the code runs. Even though the file names are different, the pdf always contains the first invoice. I also tried running the report from a variable that I cleared first. This gave the same results.
I also tried the download function.
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000000.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000001.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000002.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000003.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000004.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000006.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000007.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000012.pdf
07/15/2011 03:50 PM 1,200,495 SalesInvoice_SPI000016.pdf
07/15/2011 03:51 PM 1,200,495 SalesInvoice_SPI000017.pdf
07/15/2011 03:51 PM 1,200,495 SalesInvoice_SPI000018.pdf
Any help would be appreciated.
Thanks
Joe
0
Answers
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
You do not need to get the record (use the FINDFIRST). Only filters are passed to the report and you know that the record exists, you do not need to get it...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thank you for the solution. It works perfectly now. Appreciate the quick response.
Joe