cancel
Showing results for 
Search instead for 
Did you mean: 

Sending email of failed instances

Former Member
0 Kudos

Hi,

I am using a sample code from SAP note for sending emails on failure notification. How and where should i configure the JSP code? Do i have to configure for each and every report? Do i have to set up SMTP in the job server?

My requirement is to send emails to each user when their report fails. Is that possible?

Appreciate your help.

Thanks,
Arun

Accepted Solutions (1)

Accepted Solutions (1)

mgrackin
Contributor
0 Kudos

1) YES you need to setup the Email Destination in the Job Server.

2) YES you need to set this for each report.  Each Webi Document schedule has Notification destinations.  There is a Success notification and a Failure notification which may be sent.

3) YES it is possible to send email to each user if the job fails by using the Notification destinations.

Former Member
0 Kudos

Thanks Michael.

1) YES you need to setup the Email Destination in the Job Server.


- If there are many users whose reports failed, how can i create destination address to all the users.


2) YES you need to set this for each report.  Each Webi Document schedule has Notification destinations.  There is a Success notification and a Failure notification which may be sent.


- There are reports already scheduled, how can i add notifications? Because my understanding is notifications can be created only when you do Schedule now


3) YES it is possible to send email to each user if the job fails by using the Notification destinations.


- I have a JSP code which capture all the failed instance, but i need it to be customized to sent only to users whose reports failed. Any help?

mgrackin
Contributor
0 Kudos

Arun,

The Email Destination on the Job Server does not control who gets the notifications.  It is only used to setup defaults and define the email server to send to.

The Notifications that may be sent when the schedule Fails or Succeeds, are set via the CMC on each existing schedule or may also be set using the SDK.  The notifications are part of the SI_SCHEDULEINFO properties of the schedule infoobject.  The notifications maybe sent to specific email addresses.  Each schedule notification allows for specifying TO, CC and BCC email addresses.  So you could set them to send notifications to the user and to yourself as the administrator.

I recently built a process using the Java SDK that pulls a list of existing recurring document schedules and sets the Success and Failure notifications to send emails to myself.  It is possible to pull the SUBMITTER from the schedule and set that as the TO email address in the notification email.  The process I created is designed to be run regularly so if a user creates a new recurring schedule it will be modified to include notifications.

It sounds like your process is designed to find failed schedule instances after they ran and then email users about the failures.  If you change your process to set the notifications built into the BusinessObjects scheduling process, it will leverage the notification functionality of BusinessObjects which should make what you are attempting to do a bit easier.  The notifications only need to be set once for the recurring schedule and you're done.  Once the Notifications are set on a schedule, BusinessObjects will automatically send Success or Failure notifications when the schedule runs.  Therefore, you will not need to search for failures anymore.

Former Member
0 Kudos

Hi Micheal,

Thank you for the reply.

I can set up notifications in the BO CMC for each recurring instances. But after setting up the notifications, there is no option of saving it. The only option i see is "Schedule" and "Cancel".

So after setting up the notification i have to schedule the job to run. I don't want to run the job now, it should run only at the scheduled time.

For example- Job X, i am going to BO > CMC> Right click the schedule > Select Notifications > Enter email id and details > Two buttons i see "Schedule" and "Cancel". So the report get scheduled immediately.

If i run the same report again, i won't get the email notifications. Which means the notification is good only for that instance not for future instances.

Thanks,
Arun

mgrackin
Contributor
0 Kudos

Adding Notifications to an existing schedule is actually rescheduling the schedule as you already figured out.  Therefore you must click the Schedule button.  It is unfortunate that adding Notifications isn't a separate action.

Since this is a "reschedule" action, make sure the schedule Date/Time is set correctly in "Recurrence" for when you want it to execute for the first time.  Also, make sure your specify "Replace existing Schedule" under "Replace".

mgrackin
Contributor
0 Kudos

Make sure you are adding Notifications to the recurring schedule, not each result instance.

Former Member
0 Kudos

Thanks Michael.

I cannot do that because all are user reports and tons of them. Manually rescheduling with time and date will be crazy. Anyways my objective was to get the failed instance emailed to the user automatically. I think i have to go through SDK approach.

Arun

mgrackin
Contributor
0 Kudos

I agree you should use the SDK.  Use the SDK to identify recurring document schedules and enable the Notifications for all of them.  I just ran a process yesterday using the SDK to update the notifications on 74 recurring document schedules in one of our reporting areas.  I realize you have a lot more than 74 but I think this would be the best approach.

Once I figure out how to post code snippets into an SCN post I will give you some Java code that hopefully will be helpful.

Mickey

Former Member
0 Kudos

Thank you Michael, appreciate if you can give some snippets to update the recurring schedule with notifications.

Answers (1)

Answers (1)

mgrackin
Contributor
0 Kudos

The following is the main code used to set the notifications on recurring schedule objects.  I hope it helps move you forward into setting notifications.

argTargetIStore is the IInfoStore and is necessary to get the destination plugin.

argIStoreDocument is the document schedule IInfoObject in the IInfoObjects collection returned from the Query.

argDestinationType is used to tell the code which Notifications to set, SuccessNotifications or FailureNotifications.

argDocObject is a Java object I defined that contains properties from the document schedule IInfoObject that were populated by other code.  This is not necessary for your code but it will give you some ideas as to what I am doing with the document schedules.

Make sure you commit the IStore after making changes to the Notifications.


private static boolean resetNotifications(IInfoStore argTargetIStore, String argTargetCMS, IInfoObject argIStoreDocument, String argDestinationType, DocObject argDocObject) {

String newline = "\n";

try {

      ISchedulingInfo docSchedulingInfo = argIStoreDocument.getSchedulingInfo();

      INotifications theScheduleNotifications = docSchedulingInfo.getNotifications();

      IDestinations theDestinations = null;

      Iterator theDestinationsIt = null;

      int totalDestinations = 0;

      switch (argDestinationType) {

      case "SuccessNotifications" : {

           theDestinations = theScheduleNotifications.getDestinationsOnSuccess();

           theDestinationsIt = theDestinations.iterator();

           totalDestinations = theDestinations.size();

           break;

           }

      case "FailureNotifications" : {

           theDestinations = theScheduleNotifications.getDestinationsOnFailure();

           theDestinationsIt = theDestinations.iterator();

           totalDestinations = theDestinations.size();

           break;

           }

      }

      IDestinationPlugin destPluginSMTP = harvestDestinationPluginSMTP(argTargetIStore);

if (destPluginSMTP != null) {

if (totalDestinations > 0) {

Explore.actionLogger("--Destinations exist in the destinations object",5);

} else {

ISMTPOptions theScheduleOptions = (ISMTPOptions) destPluginSMTP.getScheduleOptions();

theScheduleOptions.setSenderAddress("senderemail@wherever.com");

theScheduleOptions.setSubject(argTargetCMS.toUpperCase() + " - " + argDestinationType);

theScheduleOptions.setMessage( "Instance: %SI_NAME%" + newline +

"Location: " + argDocObject.getFolderPath() + newline +

"Submitter: " + argDocObject.getScheduleProperties().getSubmitterName() + newline +

"Frequency: " + argDocObject.getScheduleProperties().getScheduleFrequency() + newline + newline

);

if (argDocObject.getScheduleProperties().getScheduleDestination() == null) {

theScheduleOptions.setMessage(theScheduleOptions.getMessage() + "DEFAULT DESTINATION");

} else {

switch (argDocObject.getScheduleProperties().getScheduleDestination()) {

case ISMTP.PROGID : {

theScheduleOptions.setMessage(theScheduleOptions.getMessage() +

"From: " + argDocObject.getScheduleProperties().getSenderEmailAddress() + newline +

"To: " + argDocObject.getScheduleProperties().getScheduleDestTOAddresses() + newline +

"CC: " + argDocObject.getScheduleProperties().getScheduleDestCCAddresses() + newline +

"BCC: " + argDocObject.getScheduleProperties().getScheduleDestBCCAddresses() );

break;

}

case IFTP.PROGID : {

theScheduleOptions.setMessage(theScheduleOptions.getMessage() +

"FTP DESTINATION");

break;

}

case ISFTP.PROGID : {

theScheduleOptions.setMessage(theScheduleOptions.getMessage() +

"SECURE FTP DESTINATION");

break;

}

default : { theScheduleOptions.setMessage(theScheduleOptions.getMessage() + "UNKNOWN DESTINATION"); break; }

}

}

theScheduleOptions.setAttachmentsEnabled(false);

List destTOAddressesList = (List) theScheduleOptions.getToAddresses();

destTOAddressesList.clear();

destTOAddressesList.add(usersemail@wherever.com);

List destCCAddressesList = (List) theScheduleOptions.getCCAddresses();

destCCAddressesList.clear();

List destBCCAddressesList = (List) theScheduleOptions.getBCCAddresses();

destBCCAddressesList.clear();

theDestinations.add(ISMTP.PROGID);

IDestination theDestination = (IDestination) theDestinations.get(0);

theDestination.setFromPlugin(destPluginSMTP);

} // End IF

} else {

return false;

} // End IF

return true;

} catch (SDKException e) { return false; }

}

Former Member
0 Kudos

Thanks much Michael. Appreciate it.