Sales Invoice Report Print to PDF, Number of Copies
-
Sales Invoice Report Print to PDF, Number of Copies
Posted by DSC Communities on July 25, 2017 at 10:19 am-
Justin Falconer
MemberJuly 25, 2017 at 10:19 AM
We are on NAV 2016 CU6 and we use E-Ship to send Sales Invoice Emails and we attach a PDF file with the Invoice to the Email.Ā One of our customers reported to us that the PDF file on the Email included multiple copies of the invoice.Ā In looking at this we have found that it is due to the field on the customer card for “Invoice Copies” being set to something other then 0.Ā With this customer it is set to 2 copies as they also require paper Invoices and want us to mail them 3 copies.Ā By setting this number to 2 copies we get 1 original and 2 copies to send to them.Has anyone added code to the Sales Invoice Report so that if it is exported to PDF the number of copies is set to 0 so it only exports one copy of the Invoice to PDF?
I have researched this but have not found a way to tell in code that this is being run as an export to PDF.
——————————
Justin Falconer
IT Manager
Tender Corporation
Littleton NH
—————————— -
Ian Ray
MemberJuly 25, 2017 at 11:31 AM
Are you by any chance printing the PDF upon posting the invoice and printing the paper copies from the posted sales invoice?Ā(Edit: ignore the second sentence I posted previously, that doesn’t work)
——————————
Ian Ray
Cypress Grove
Arcata CA
——————————
——————————————- -
Justin Falconer
MemberJuly 25, 2017 at 2:56 PM
This is normally done as a Batch Print.Ā The Eship Email is sending the Invoice at time of posting, but the print is being done in Batch.——————————
Justin Falconer
IT Manager
Tender Corporation
Littleton NH
——————————
——————————————- -
Ian Ray
MemberJuly 25, 2017 at 6:33 PM
How about this…If your first print is always going to be 1 page, we can look at Sales Invoice Header.No. Printed to decide how many copies to print.
Add a C/AL Global “SalesInvoiceHeader” “Report” “Sales Invoice Header”
In the “Sales Invoice Header – OnAfterGetRecord()” section
SalesInvoiceHeader.GET(“No.”)Ā
In the CopyLoop – OnPreDataItem() section, after the NoOfLoops := bit
IF SalesInvoiceHeader.”No. Printed” < 1 THENĀ
NoOfLoops := 1;I tested this briefly. What happens is when No. Printed = 0, only one copy prints regardless of settings for Number of Copies or Invoice Copies on customer card. Once No. Printed = 1, the copies go back to normal.
The only issue here would be if you really needed to print multiple copies for the first print job. But, if the first print job is automatic, this shouldn’t be a problem.
——————————
Ian Ray
Cypress Grove
Arcata CA
——————————
——————————————- -
Paul Turner
MemberJuly 26, 2017 at 7:42 AM
Another idea – if you have access to modify the function that creates the PDF copy, you could do this:- Create a new function in the invoice report object that accepts a Boolean value as its only parameter (named something like SetPDFPrint).Ā This function will set a new global Boolean variable (named something like PDFPrint) equal to the value of the parameter.Ā No return value on the function.
- Modify the code in the invoice report where it is going through the copy loop to change the number of loops to 1 if the PDFPrint global variable is true.Ā Any other functions outside of your PDF function that call this report will not be calling your new function, so by default this variable will be false and will not affect other standard functionality.Ā If this is report 10074 for example, you would do this in the OnPreDataItem trigger of the CopyLoop data item.Ā Add something like “IF NoLoops > 1 and PDFPrint THEN NoLoops := 1”
- To use this new global function you need to create a variable of type Report pointing to your invoice report so you can call that function then run the report from the same instance (unless the PDF function is already using a report variable).Ā Basically if the function that creates your PDF invoice is printing this report with a line like, “REPORT.RUN(10074, FALSE, TRUE, Rec);” then you need to change this.Ā So if you name your report variable “InvoiceReport,” then you would replace this line of code with these three lines: “InvoiceReport.SetPDFPrint(TRUE); InvoiceReport.Settableview(Rec); InvoiceReport.Run;”Ā Or if the PDF function is already using a report variable then you only have to add the “InvoiceReport.SetPDFPrint(TRUE);” line.
Hope this is helpful or at least interesting to someone š
——————————
Paul Turner
Liberty Mountain
Sandy UT
——————————
——————————————- -
James Ellard
MemberJuly 26, 2017 at 8:29 AM
?HiWe had a similar problem with automated sending throughĀ Zetadocs where we need to print multiple hard copies but only 1 document if a PDF is being generated.
We overcame this outside of NAV, we left all ‘copies’ in NAV set to 0. We then modified the Windows default printer settings to install another print driver where the number of copies was set up on the printer preferences. We then pointed the sales invoice report to this print driver through ‘Printer Selections’. Any hard copies now get printed multiple times and PDFs just contain the original document.
I am not sure if this will work in your circumstances if the number of copies is dependent upon the customerĀ but thought I would mention this as a possible alternative to modifying NAV.
——————————
James
——————————
——————————————-
DSC Communities replied 8 years, 2 months ago 1 Member · 0 Replies -
-
0 Replies
Sorry, there were no replies found.
The discussion ‘Sales Invoice Report Print to PDF, Number of Copies’ is closed to new replies.