SAVEASPDF Function

jflynn
Member Posts: 34
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
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
-
try with
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 SalesInvHeader2.RESET; SalesInvHeader2.SETRANGE("No.",SalesInvHeader."No."); IF SalesInvHeader2.FINDFIRST THEN REPORT.SAVEASPDF(REPORT::"WL Sales Invoice",ToFile,SalesInvHeader2); UNTIL SalesInvHeader.NEXT = 0;
0 -
SalesInvHeader2.RESET; SalesInvHeader2.SETRANGE("No.",SalesInvHeader."No."); IF SalesInvHeader2.FINDFIRST THEN REPORT.SAVEASPDF(REPORT::"WL Sales Invoice",ToFile,SalesInvHeader2);
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...0 -
Kamil and Mohana,
Thank you for the solution. It works perfectly now. Appreciate the quick response.
JoeJoe0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions