NetTalk Central

Author Topic: Calling Multiple Print Routines from one form  (Read 3246 times)

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Calling Multiple Print Routines from one form
« on: June 10, 2013, 11:49:04 AM »
I have a NetWebFrom that depending quite a lot of different conditions needs to call one of many print routines.

The end user needs to see just one print button.

Originally I had lots of print buttons, and hide all but the relevant one using the standard hide condition on the button. The problem is, that these conditions have become so complex, that I've actually run out of room to type in the condition (or at least it's getting truncated when generated)

I decided that it would be easier (Maybe??) to have a single print button, that calls a NetWebSource procedure that has all of my conditional logic in it, which in turn calls the relevant print routine. It just about works, by embedding my code in the "Before Div Header" and then returning.

The only problem I have, is if I get an alert message from one of my reports saying nothing to print, then that message gets displayed as a bit of source code (or similar) in the browser window.

Is there a better way of doing this?

Regards,

Neil Porter

C8.9661  NT 6.51
Clarion 11.0.13244
NetTalk 11.04

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Calling Multiple Print Routines from one form
« Reply #1 on: June 10, 2013, 04:17:34 PM »
Hi Neil,

Have you tried putting all your logic on the server side when a user clicks the button?

Cheers,

Kevin

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Calling Multiple Print Routines from one form
« Reply #2 on: June 11, 2013, 02:26:32 AM »
Good idea Kevin, I hadn't tried that.

The rub is that I want to server the pdf that my report creates in a new tab, so i need to set the target to be '_blank'

I've tried the following code in the Server Code embed:

CASE p_web.GSV('MyLabelType')
OF '1'
  PrintLabelType1(p_web)
OF '2'
  PrintLabelType2(p_Web)
END

I've also tried calling

p_web.Windowopen('PrintLabelType1','_blank')

Which looks like the code generated by a standard button, but although I can see that my label routine is called, I don't get a pdf displayed to the browser.

Any thoughts?

Regards,

Neil.
Clarion 11.0.13244
NetTalk 11.04

MikeR

  • Sr. Member
  • ****
  • Posts: 257
    • View Profile
    • Email
Re: Calling Multiple Print Routines from one form
« Reply #3 on: June 11, 2013, 03:28:43 AM »
Instead of having the button call printRoutine1 and another Button printRoutine2

Create a new source procedure called choosePntRoutine, or whatever.
make sure it has a parameter called p_web. ier the saem as the print routines.

Put all the logic into the source procedure to determine which print routine to call

ie.

if  p_web.gsv('CallRtn') = 'prtrtn1'
   prtrtn1(p_web)
end


The -Blank will still work and a new pdf page will be displayed.
 

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Calling Multiple Print Routines from one form
« Reply #4 on: June 11, 2013, 05:43:59 AM »
Mike,

That's what I'd done to start with, and it does work until I have the situation where the report returns the alert "No Records Found" When that happens the alert doesn't display properly.

I'm wondering if I'm putting my my code in the wrong embed in the Source procedure?

My code is in the "before Div Header" embed.This is the only embed that I found that doesn't seem to try to format my call as HTML.

Regards,

Neil.
Clarion 11.0.13244
NetTalk 11.04

MikeR

  • Sr. Member
  • ****
  • Posts: 257
    • View Profile
    • Email
Re: Calling Multiple Print Routines from one form
« Reply #5 on: June 11, 2013, 06:22:54 AM »
It must be a normal Clarion Source procedure
not a nettalk one.
it must just have the same parameters past to it . ie p_web.

The normal clarion sourcve procedure will determine which report proecdure to call with the nettalk extention

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Calling Multiple Print Routines from one form
« Reply #6 on: June 11, 2013, 12:13:14 PM »
Mike, I must be doing something stupid.

If I convert my netwebsource procedure to be a normal Clarion source procedure, I can't call that procedure from a button. I get an error saying the "page cannot be found" which kinda makes sense as it isn't a web procedure any more.

If I call my clarion source from the server code of my button, surely I'm back to square one, because I can't set my print procedure to have a target _blank.

I'm lost....

Regards,

Neil.
Clarion 11.0.13244
NetTalk 11.04

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Calling Multiple Print Routines from one form
« Reply #7 on: June 11, 2013, 03:03:23 PM »
Hi Neil,

At what point do you know the report name? ie as the form opens or after they do some stuff on the form?

Cheers,

Kev

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Calling Multiple Print Routines from one form
« Reply #8 on: June 11, 2013, 11:31:15 PM »
Hi Kev,

After they've filled a load of data into the form. That determines what report gets called.

Regards,

Neil.
Clarion 11.0.13244
NetTalk 11.04

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Calling Multiple Print Routines from one form
« Reply #9 on: June 12, 2013, 01:20:25 AM »
ok, try this...

For your print button add a URL but make it a session value

Create a routine for your report logic and move it from the report button into this routine. In this routine update the session value added to the report button to the report you want to run.

As a user fills in info call this routine and add the print button to the refresh list. This will update the URL on the browser.

Let us know how you get on...

Cheers,

Kevin

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Calling Multiple Print Routines from one form
« Reply #10 on: June 12, 2013, 09:58:20 AM »
Kevin, what a cool idea.

It works like a charm!

Thank you very much for your help.

Regards,

Neil.
Clarion 11.0.13244
NetTalk 11.04