View Full Version: POSSIBLE SOLUTION to "DO NOT EXPORT IF BLANK"

kgroff >>Feedback >>POSSIBLE SOLUTION to "DO NOT EXPORT IF BLANK"


<< Prev | Next >>

neil111- 12-14-2005
POSSIBLE SOLUTION to "DO NOT EXPORT IF BLANK"
Hi. I think I have a solution and would like your input. It is a different approach than trying to find out if records were returned by CR, and offers some flexibility for the user. I also believe it uses existing CD functionality so would not be too time consuming or difficult to add in the current release (but I'm not the judge of that, of course :-). The Proposed Solution: After exporting the file to its destination folder, check the resulting file size. In most cases, even with headers & footers, a report with no records will be very small in filesize. I just tested one of mine with a selection criteria of 1=0 (so no records were generated), and the resulting .pdf was 10.3KB. My suggestion is to add the following options to the crystal report settings screen in the Export Prompt Section: - Export File Size Lower Limit: ____ KB (leave blank if always export) - Delete File if smaller than limit?: Y/N - E-Mail address to notify of "lower limit" condition: ____________ Then, after the file is exported, have CD check the resulting file size. If the size is less than the lower limit specified by the user, then possibly delete it, and then send a notification e-mail (not to all users that are subscribed, but just to the specified recipient for this condition) indicating the report was created but that its size was too small to be distributed. I trust that when the usual destination of the export is to e-mail to users, a "temporary file" is saved somewhere on the local hard drive before it is attached to the outbound e-mail, and this is the point where the above logic would be applied. I welcome and look forward to any/all comments on the above from the community. Kevin, hopefully you think will work. Thanks, - Neil

kgroff- 12-14-2005

Something like this would be fairly easy to incorporate. I will see about adding it in the near future. Thanks.

JohnW- 12-16-2005

Something to consider when doing a filesized based cull on your report is that timestamps will update on an empty report. This would theoretically change the filesize by a slight margin (depending on how many stamps were in a given empty report). You'd want to be sure to err on the side of larger file sizes to delete. I recently had to tackle this problem myself. Below is my method, definately not for the sane or faint of heart. Make a text field containing a unique phrase on your report. Set it to suppress conditionally when: Not(Isnull(Count({dbo_Accounts.AccountID}))) or Count({dbo_Accounts.AccountID}) > 0 The logic is that it will only show the unique phrase on an empty report. {dbo_Accounts.AccountID} is simply a number field found in my report that does exist on a normal report, while it does not exist on an empty report. Any report field should work. Using xpdf's tool pdftotext, I translate the first page of the output pdf file to a text file (my unique word field is on the first page), and use findstr (nifty xp command line file scanner) to search for the unique phrase. If findstr hits, I delete the text file, and the empty pdf. Otherwise, I just delete the text file. Ugly as sin, but it automates :)

kgroff- 12-19-2005

Finally, thanks to some input from JohnW, CD can generate an alert if a report is empty. This option is found by pressing 'Config'. The alert email now includes the parameter settings for the report the generated the alert.

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.