Tutorial 8-6. Using Parameters with Report Alerts
Crystal Reports comes with an excellent example of a report that not only uses report alerts, but combines it with report parameters. The sample report, Alerting.rpt, prompts the user for a sales amount that they want to be alerted to. The user enters an amount and if any records have a sales amount greater than that amount, then the report alert is triggered and the records are shown to the user. In addition to that, the report alert message uses that parameter to customize the alert message so that the dollar amount is also shown within the message. This example links together parameters with report alerts with the alert message. We’ll walk through it to see how it works.
- Open the Crystal Reports sample report Alerting.rpt.
- Look in the Field Explorer and find the parameter Amount of Sales. Right-click on it and select Edit.
- Examine the parameter to see that it is a static parameter which asks the user to enter a specific dollar for sales amount. When done reviewing this parameter, close the Edit Parameter dialog box.
- Examine the existing report alert by selecting Report > Alerts > Create or Modify Alerts. The Create Alerts dialog box opens and it has the Sales alert listed. Click on the Edit button to open the Create Alert dialog box.
- Notice that the Message input box is empty. That is because the message is created using conditional formatting. Click on the Formula Workshop button and you’ll see the following formula:
"Sales are greater than " + totext({?Amount of Sales})
- This formula uses the parameter Amount of Sales and appends it to the end of the text, “Sales are greater than”. This makes the message dynamic so that it always displays what the user entered as the parameter value when the report was refreshed. Of course, you wouldn’t want to hard-code a value here because the sales amount is always changing.
- Close the Formula Workshop when you are finished reviewing the formula. Click on the Condition button to open the Formula Workshop again and this time it displays the following Condition formula:
{Customer.Last Year's Sales}> {?Amount of Sales}
This formula triggers an alert whenever the dollar value of last year’s sales is greater than the parameter value entered by the user. Again, the parameter is used within the alert so that it is derived from the user’s choice.
- Close the Create Alert dialog box. Refresh the report and select the option to prompt for parameter values. Enter a dollar value and look to see if any records generate a report alert. If so, you’ll see that the alert message states the dollar value you entered as the parameter.
This example showed you how effective it is to link the parameters with report alerts to create a dynamic report. You could also add conditional formatting that uses the alert functions to make the records which caused the alert to stand out.