Crystal Reports - change based on print or email?  Topic is solved

Support for Crystal Reports within Jiwa.

Crystal Reports - change based on print or email?

Postby neil.interactit » Thu Oct 15, 2015 3:41 pm

Hi guys,

I have a requirement from a client ... they want to use letterhead for printing and so need Crystal to print without logo etc (which is preprinted) but still email with logo etc.

Programmatically displaying the logo etc or not within Crystal is no problem ... this question is whether there is a way I can determine within Crystal whether the report is being printed or emailed?

This is for a Debtors / Statements type report, where there are no JiwaRanges parameters per se ... and even if there were, the client would prefer relying only on the "print" or "email" button, rather than also needing to set a print/email parameter.

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Crystal Reports - change based on print or email?

Postby Scott.Pearce » Mon Oct 19, 2015 4:31 pm

So you are using the Statements form yes?

My first instinct was to tell you to simply do the statement runs in "batches". For example, on the statements screen, click the "Use Groups" check-box and choose "from group" and "to group" to be "Statement - Email" (this assumes debtors have already been assigned to the appropriate group). Then change the report to be the one with the logo included. Perform the statement run. Then, change the "from group" and "to group" to be "Statement - Print", change the report to be the one *without* the logo, and perform the statement run.

The above is very programmer-like though, is it? I'll go and have a play in plugins to see if its possible to automatically select the report on a full statement run based on whether Print or Email was clicked (regardless of debtor). I'll post back here soon.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Crystal Reports - change based on print or email?

Postby Scott.Pearce » Tue Oct 20, 2015 9:14 am

I've found some events in the statements form that you could use:

EmailingBatch - occurs at the start of a run when emailing.
EmailedBatch - occurs at the end of a run when emailing.
PrintingBatch - occurs at the start of a run when printing.
PrintedBatch - occurs at the end of a run when printing.

The list of debtors and the report are passed in as parameters. In EmailingBatch, you could either manipulate the report itself, or swap in a completely different report (one that has the logos).
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Crystal Reports - change based on print or email?

Postby neil.interactit » Tue Oct 20, 2015 12:34 pm

Hi Scott,

I can see into the report definition, and for example, have examined reportdefinition.Report.GenerateSQL(). I can see from this that FileName = 'Version 7 - Debtors Statement Portrait.rpt', so swapping the entire report should be just assigning a new value to reportdefinition.Report.FileName I guess.

If possible, my preference would be to manipulate the report itself if possible - allowing a more generic approach across reports - but all I can spot appears to be Base64 or Binary. Is it possible to manipulate something here that essentially sets @PASS_OutputType = "PRINTING" (or "EMAILING") as it passes through, so that I can pick up the value in Crystal and work with it there?

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Crystal Reports - change based on print or email?  Topic is solved

Postby Scott.Pearce » Wed Oct 21, 2015 9:49 am

neil.interactit wrote:so swapping the entire report should be just assigning a new value to reportdefinition.Report.FileName I guess.


Nope. You would do a Report.ReadRecordFromFileName("Filename as it appears in reports configuration form.").

neil.interactit wrote: Is it possible to manipulate something here that essentially sets @PASS_OutputType = "PRINTING" (or "EMAILING")


You would do it like this inside the events noted in my previous post:

1. Save the file binary (Report.FileBinary) out to a file (say in the users temp folder).
2. Read the file in as a crystal report object.
3. Manipulate the crystal report.
4. Save the manipulated report back out to a file (say in the users temp folder).
5. Read the manipulated report from the file into the Report.FileBinary byte array.

We do this in various places in our print engine. I can help you out with code snippets if you need anything particular (i.e. how to read a file in as a crystal report object, etc.)
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221


Return to Crystal Reports

Who is online

Users browsing this forum: No registered users and 15 guests