Ver 7.7.8 .GetBytesPDF() problem

I’ve been asked to add the ability to email reports to an existing project I did for a client on 7.7.8.

I’ve got the email aspect working fine and and report generation working fine but every other email has an empty PDF file while other times, the PDF has the actual report in it. It’s not consistent. The email is done thorugh a client script but I’ve been testing with a PB script on a client window.

Here is the code from one of the reports:

import time
import system
from java.util import Date

currentdate = Date()
todayDate = system.db.dateFormat(currentdate, "MMM dd yyyy E hh:mm a") 

window = system.nav.openWindowInstance('Popups/Report')
time.sleep(30) # Wait for report values to update

Report = system.gui.getWindow('Popups/Report').rootContainer.getComponent("Sales Report")	
emailName = [" Sales Report.PDF"]
title = "Sales Report for (" + str(todayDate) + ")"
body = "Please find attached the Sales Report"
# Email Settings for changing to email report instead of printing
recipients = [""]
emailuser = ""
emailpassword = "password"
emailData = [Report.getBytesPDF()]"", fromAddr=emailuser, subject=title, body=body,
html=1, to=recipients, attachmentNames=emailName, attachmentData=emailData, username=emailuser, password=emailpassword)

Since we’re opening the report window when we want to print, I initially added a delay to allow for the data to be updated from the database and I’ve tried other delays after the .GetBytesPDF() in case it took time but in any case, sometimes the PDF attachment is correct, sometimes it’s empty.

Any suggestions?

Can’t upgrade the server. :slight_smile: