In addition to being able to trigger alerts upon completion of a scheduled job, there are multiple notifications that can be set up. These are typically targeted for the consumption of Crystal Enterprise administrators as opposed to end users. There are two types of notifications: audit notification and e-mail notification.
There are two audit notifications that can be turned on: one for the success of a report job and one for the failure of a report job. When either of these audit notifications is enabled and a job finishes, a record is written to the auditing database indicating the job name, time, status, and so on. To enable audit notifications, call the getNotifications method of the ISchedulingInfo interface. This returns an INotifications interface. Using this interface, the setAuditOption method can be called, passing in a member of the CeAuditOnResult enumeration. The valid values are
The following example schedules a report and enables audit notification for a successful job:
ISchedulingInfo sched = report.getSchedulingInfo(); sched.setRightNow(true); INotifications notify = sched.getNotifications(); notify.setAuditOption(INotifications.CeAuditOnResult.SUCCESS); iStore.schedule(results);
Email notification works in a similar manner. It can be enabled for both successful and failed jobs. To enable email notification, obtain the INotifications interface as described previously like you would do for auditing. From there, you can call the getDestinationsOnSuccess or getDestinationsOnFailure methods to obtain the IDestinations interface. You might recognize this interface as the same one used to configure schedule destinations. To enable email destinations using the Report Job Servers default email settings, you can simply call the IDestinationss add method passing in CrystalEnterprise.Smtp as shown here:
ISchedulingInfo sched = report.getSchedulingInfo(); sched.setRightNow(true); INotifications notify = sched.getNotifications(); IDestinations dest = notify.getDestinationsOnSuccess(); dest.add("CrystalEnterprise.Smtp"); iStore.schedule(results);
If you want to customize the e-mail settings such as the recipients, subject line, and so on, you can call the getScheduleOptions method and get access to the ISMTPOptions interface.