Pass Report Parameter to Crystal Reports & E-mail Address to Report Commander2

JimmyC (7 posts)
April 14, 2020 01:19 PM
Accepted Answer

I seek help on how to automate the Crystal Reports generation of a PDF report and e-mail it to different users. 

The Crystal report needs to be provided a six digit batch number in order to generate the report---once Crystal Reports generates the PDF report, I need to e-mail the PDF to a specific user --so I need to provide Report Commander2 the e-mail address.   The cycle then repeats---provide Crystal with a new batch number, Crystal Reports generates the PDF report and I provide a different e-mail address to Report commander2 to attach the PDF and complete the e-mail sending process.  Each day, there could be anywhere from 5 batch numbers to 35 batch numbers---so the daily number of iterations in Crystal Reports to create the PDF's will vary.   I could create a CSV file, with a column for the batch # and a column for the e-mail address if this would help--if ReportCommander2 can "read" a CSV.   Any advice on how this may be accomplished in Report Commander2? 

 

Thanks

JimC 

Bill Staff (599 posts)
April 14, 2020 02:07 PM
Accepted Answer

To pass the batch number to the report, you would need to add this as a parameter for the report, and have the appropriate record selection logic in the report based on the parameter. You then set the parameter on the Report Commander command line, and Report Commander passes it to the report.

To automate and repeat this, you're going to need to run Report Commander separately for each batch number, giving it both the batch number (using the -parameters option so it passes it through to the report) and the email address (using the -emrecipient option). Refer to the command line syntax help topic for details.

So assuming it's a program or script that you have generating the list of batch numbers and email addresses, you would need to modify that to produce command lines instead--your program could generate a batch file that has all the commands to execute for the day.

(For Report Commander 3 we are adding "bursting" capability, where Report Commander could automatically split the report and email each batch to a different email address, but that doesn't help you since it's a ways off.)

Let me know if you need more details on how to set this up.

JimmyC (7 posts)
April 14, 2020 02:31 PM
Accepted Answer

Bill,

Thank you...I will working on this during the next several days and will post back my progress---or more likely where I need some more guidance.  I trust all is well with you and your family.  Stay safe and healthy.   JimC 

JimmyC (7 posts)
April 16, 2020 09:04 AM
Accepted Answer

Bill,

Ok I am officially stuck in the mud.

I am using Crystal Reports 2013.  I believe I have successfully create the crystal report as it prompts for the batch number when data is populated.

Below is a screen shot of the parameters tab in Report Commander 2.6:

 I am guessing there is another step as when I preview/execute the report, I get this:

 

 I haven't even made it to customizing report commander to prompt/accept for the outbound e-mail address.  

 Any help is greatly appreciated.

JimC 

JimmyC (7 posts)
April 16, 2020 10:13 AM
Accepted Answer

I am making some progress, though it is at a brutally slow pace.   When I preview the report, enter the batch number it works:

But when I execute (i.e., I am sending to my home e-mail account since I have not discerned how to make the sending e-mail address a variable yet), I see this:

 

 Thanks for your time and patience.

 

Bill Staff (599 posts)
April 16, 2020 04:35 PM
Accepted Answer
Not sure what would be causing the "Object not set..." error but the error in your second post indicates that you have not set a value for the parameter. On the Parameters page you need to Edit the parameter and set a value before you execute. Report Commander does not prompt you for parameter values because it is designed to run reports unattended. It is also not going to prompt you for an email address. Once you have it working in the Command Line Builder, go to the Command Line tab and it will show you the command line you need to execute the report with the current settings. You will take this command line and have your program generate the same command line for each batch you need to run, changing the batch number and email address on the command line.
JimmyC (7 posts)
April 17, 2020 05:25 AM
Accepted Answer
Bill--thanks for the reply.   I am still working through the occasional "object not set" issue but thank you for your clarification on the "prompts" regarding Report Commander.  I was operating under the wrong assumption---expecting a prompt at some point.  I am now struggling more whether this report process can be automated.  I have been trying to "re-concatenate" the report commander command line to substitute the dynamic e-mail address and batch #.  One issue is the batch #'s and e-mail addresses are not directly linked--I need some form of a "look-up" process as the batch # relationship changes daily as new batch numbers are created.   I have not been able to successfully "re-concatenate" the command line yet, though I have been able to take the command line without modification (i.e., leaving the batch # and e-mail "fixed" from my original creation of the command line string and drop it into a CMD window and it runs.  I was hoping to be able to somehow "re-concatenate" the command line string and then  copy it to the CMD window automatically but this approach appears unworkable without significant human interaction.   I can't seem to find the "software" to help me modify command line string automatically or certainly without the significant human intervention I have experienced so far.   Any advice is welcome!! JimC
Bill Staff (599 posts)
April 17, 2020 06:44 AM
Accepted Answer

Where is this list of batch numbers and email addresses coming from each day? You said in your original message that you could provide a CSV file of this information. Is this CSV file coming from another program or are you creating it by hand or what? If you are not a programmer, you are probably going to need one to write you a simple program or PowerShell script or Excel macro or something similar that can take the list of batch numbers and email addresses and generate the command lines for you.

You might also consider purchasing a support subscription if you'd like more hands-on assistance with getting this set up.

JimmyC (7 posts)
April 17, 2020 07:05 AM
Accepted Answer

Bill, thanks for the reply. 

The CSV file would need to be created too.   Currently, I can generate a report using Crystal Reports 2013 to capture the daily timekeeper number and batch #.  The next task is to use the timekeeper # in some sort of a "look-up" function to locate/copy the timekeeper's e-mail address into the Excel/csv file.   I have this part working, more or less, with some manual intervention. 

I then need the batch # and "looked-up" e-mail address to modify the report commander command line.  This is why I thought maybe a concatenation process would work---changing/substituting into the report commander command line the two dynamic elements--batch # and e-mail address.  But somehow the copied concatenated value to the CMD window does not work--even though to the naked eye the line looks exactly like the command line I copy from report commander to the CMD window without alteration. Excel's concatenation function must place something unseen into the command line as the "modified/concatenated command line won't run like the "original" report commander command line.   

Let me ponder more this weekend and also speak with my boss as to whether I can secure authorization for the support subscription.    I will post back with an update early next week.   Again, thank you for all of your advice.   Jim

Replies are disabled for this topic.