NetTalk Central

Author Topic: How to call a report procedure so it just generates the PDF?  (Read 4027 times)

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
How to call a report procedure so it just generates the PDF?
« on: April 12, 2012, 10:51:02 PM »
I am trying to create a one click send email with attachment process on a  browse.

I have succeeded in placing a button on the browse conditionally but am struggling how to add an attachment without actually seeing the report itself.

Currently I preview the report which produces a filename and saves the report. Then I call an email form and attach the report.

What would be better would be to have the email button which when pressed generates the report, saves it, attaches it then sends it all in one.

I think I have everything in place other than how to generate the report silently as it were.

Being as the report currently generates then displ;ays it in another tab (_blank target) I need some switch in the code to turn this "previewing" off being as I want to preview the same report as normal elsewhere in the application.

Any help how to do this would be greatly appreciated,.

Thanks

John
« Last Edit: April 12, 2012, 10:54:22 PM by John Fligg »

Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: How to call a report procedure so it just generates the PDF?
« Reply #1 on: April 13, 2012, 03:02:00 AM »
John, I am assuming that you are using just the inbuilt Clarion PDF generator to create the PDF within a report?

If so - the simplest way is to do the following within the Report procedure:

* Click on 'Actions...' then 'Report Properties'.
* In the 'General' tab, TICK the 'Print Preview' checkbox.  <- Strangely, I found problems if this was NOT ticked for some reason...
* In the 'Report Targest' tab, change the 'Report Target' drop down to 'Other'.  Change the 'Other Target' to 'PDF'
* In the 'Preview Options' tab, change 'Runtime Skip Preview' to 'True'

Ok, now go back to the Report main procedure screen and click on the 'Extensions' tab.
There should be an extension called 'Report to PDF'.  Double click on it.
* Under the 'General' tab, change the 'Output Name Type' to 'Variable'
* Under 'File Name' - either specify a variable holding your PDF filename, or specify one like '.\web\reports\MyReport.pdf'.
* All other fields are as per your preference.

This should create the PDF automatically when you call the REPORT procedure from the web app.

*** TIP: The file name you specify above is based on the APPLICATION folder, NOT the web root folder, so the file name is '.\web\reports\Report1.pdf' here, but '/reports/Report1.pdf' when called from the web app as a link etc.

I would also consider using a unique name for the PDF by using the data and time as part of the name so that multiple users don't clobber the same file if they run it at the same time.

Also, if you specify a leading '$$$' in front of the PDF filename, NetTalk should DELETE the file once it is served up to your user.  You may or may not want this to happen.  If you don't prefix the file name with '$$$', e.g. '.\web\reports\corporate\$$$profit_and_loss.pdf' then you will have to manually do some housekeeping to clean it up afterwards.

Hope this helps.
« Last Edit: April 13, 2012, 03:04:25 AM by Devan »

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: How to call a report procedure so it just generates the PDF?
« Reply #2 on: April 13, 2012, 06:26:54 AM »
Yes that is exactly what I do now (well more or less). The thing is that the report must be able to be previewed/printed as normal and also be generated automatically.

Talking to Bruce, who will hopefully chip in here (!!) the problem is that in my scenario I need to click a button, have the report generated behind the scenes and then attached to an email and sent.

My problem is how to generate the report silently in one case (no preview) but not in another. All my attempts to do that to date have failed.

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to call a report procedure so it just generates the PDF?
« Reply #3 on: April 13, 2012, 11:02:29 PM »
when you call the report procedure, right before you actually send the mail, you could do a
p_web.SetValue
then in the report procedure, test the Value, and bypass the call to p_web.Send

for example;
  p_web.SetValue('NoSend',1)
  MyWhateverReport(p_web)
  SendEmail(whatever)

and in the report
  If p_web.GetValue('NoSend') = 1
   ! don't send.

cheers
Bruce

johncorry

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • Email
Re: How to call a report procedure so it just generates the PDF?
« Reply #4 on: February 14, 2013, 04:01:36 AM »
John did you succeed  in suppressing the report preview after pdf creation and before emailing as an attachment. This seems to have come up a few times with no clear solution being documented. I am having the same dificulties you have reported.
John