cancel
Showing results for 
Search instead for 
Did you mean: 

Update Destination details of email and mail alert notification for recurring schedules

Former Member
0 Kudos

HI,

We have new requirement where the domain of the user email is getting change from @abc123.com to @abc.com. we have 400 recurring schedules in the production which has email as the destination. We also have few 100 schedules which has the notification alert enabled for success and failure status, we also need to change the email address.

I have Java sdk knowledge, but i am struggling to find a right query in place as this seem to be a big task.

please let us know the java sdk script or idea to this.

Regards

MK

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member230921
Active Contributor

https://help.sap.com/viewer/0225aa3e7b4b4b17b2d4a882e6f2de96/4.2.5/en-US/45a29be16e041014910aba7db0e...

Sample code for notification (not tested):

public void triggerNotification(IInfoObject job) throws SDKException {
              try {
                  ISchedulingInfo info = job.getSchedulingInfo();
                  INotifications notifications = info.getNotifications();
                 boolean notificationSuccess = (notifications != null && 
                          !notifications.getDestinationsOnSuccess().isEmpty() && statistics.getError() == 0);
                  boolean notificationFailure = (notifications != null && 
                         !notifications.getDestinationsOnFailure().isEmpty() && statistics.getError() > 0);
                  
                  if (!notificationSuccess && !notificationFailure) {
                      return;
               }
                 String subject = (notificationSuccess)? LogMessageUtility.getInstance().
                         getMessage("IDS_JOB_NOTIFICATION_SUCCESS", this.job.getTitle()) : 
             LogMessageUtility.getInstance().getMessage("IDS_JOB_NOTIFICATION_FAILURE", this.job.getTitle()); 
                 
                 String message = createMessage();
               IDestinations destinations = (notificationSuccess)? notifications.getDestinationsOnSuccess() : 
                     notifications.getDestinationsOnFailure();
                 for (Object obj : destinations) {
                     IDestination dest = (IDestination) obj;
                     if (!"CrystalEnterprise.Smtp".equals(dest.getName())) {
                         continue;
                     }
              IProperties props = dest.properties().getProperties(PropertyIDs.SI_DEST_SCHEDULEOPTIONS, true);
                     props.setProperty(SI_MAIL_SUBJECT, subject);
                     props.setProperty(SI_MAIL_MESSAGE, message);//set here properties
                 }
                 job.save();
             } catch (SDKException e) {
                 throw e;
             }
             
         }
Former Member

Hi Bharath,

Thanks for this extended help.

My question is that i can able to get the code of getting the success and failure address, all i can see is only the getfunctions for to mail, bcc, sender mail, cc, only for the sender mail i can see the function called setsenderaddressl for all other i was not able to do so. See my below code, i can able to modify only the senderAddress

if(webiobject.getSchedulingInfo().getNotifications().getDestinationsOnSuccess().size() !=0)

{

Dest_Succ = (IDestination) webiobject.getSchedulingInfo().getNotifications().getDestinationsOnSuccess().get(0);

if (! Dest_Succ.isSystemDefaultOptionsUsed()) { SmtpPlugin = (IDestinationPlugin) boInfoStore.query("Select Top 1* from CI_SYSTEMOBJECTS Where SI_NAME = 'CrystalEnterprise.SMTP'").get(0);

Dest_Succ.copyToPlugin(SmtpPlugin); ISMTPOptions SmtpOptions = (ISMTPOptions)

SmtpPlugin.getScheduleOptions(); SmtpOptions.getSenderAddress(); SmtpOptions.set; System.out.println("Sucess Sender Email:"+SmtpOptions.getSenderAddress());

String x=SmtpOptions.getSenderAddress();

String y=x.replaceAll("(?i)xyz", "abcdefg");

System.out.print("the value after replacement "+y);

SmtpOptions.setSenderAddress(y);

Dest_Succ.setFromPlugin(SmtpPlugin);

boInfoStore.commit(boInfoObjects);

Dest_Succ.setFromPlugin(SmtpPlugin);

}

}


Many thanks

MK

former_member230921
Active Contributor
0 Kudos

how about this?

//updateTO address here

      List toAddresses = smtpOptions.getToAddresses();

      toAddresses.add("user1@emaildomain.com");

      toAddresses.add("user2@emaildomain.com");

//update CC address here

      List ccAddresses = smtpOptions.getCCAddresses();

      ccAddresses.add("user1@emaildomain.com");

      ccAddresses.add("user2@emaildomain.com");
former_member230921
Active Contributor

Check for "Set destination to SMTP":

https://help.sap.com/viewer/0225aa3e7b4b4b17b2d4a882e6f2de96/4.2.5/en-US/45a694d86e041014910aba7db0e...

sample code:

void configureDestinationToSMTP(IEnterpriseSession enterpriseSession) throws SDKException

    {

      IInfoStore infostore = (IInfoStore)enterpriseSession.getService("InfoStore");  

      IInfoObjects reccuringInfoObjects = infostore.query("Select * from CI_INFOOBJECTS where SI_INSTANCE = 1 and SI_SCHEDULE_STATUS = 9");

      IInfoObject infoObject = (IInfoObject)reccuringInfoObjects.get(0);

     

      ISchedulingInfo schedulingInfo = infoObject.getSchedulingInfo();

      IDestinations destinations = schedulingInfo.getDestinations();

      String pluginType = "CrystalEnterprise.Smtp";

      Iterator destinationsIter = destinations.iterator();

      IDestination destination=null;

      while (destinationsIter.hasNext())

      {

          destination = (IDestination) destinationsIter.next();

          if (pluginType.equals(destination.getName()))

              break;

      }

      

      IInfoObjects smtpInfoObjects = infostore.query("Select SI_DEST_SCHEDULEOPTIONS, SI_PROGID From CI_SYSTEMOBJECTS Where SI_NAME = 'CrystalEnterprise.Smtp'");

      IInfoObject smtpinfoObject = (IInfoObject)smtpInfoObjects.get(0);

      IDestinationPlugin destinationPlugin = (IDestinationPlugin)smtpinfoObject;

      ISMTP smtp = (ISMTP)destinationPlugin;

           

      ISMTPOptions smtpOptions = (ISMTPOptions)smtp.getScheduleOptions();

      smtpOptions.setDomainName("domain");

      smtpOptions.setServerName("servername");

      smtpOptions.setPort(Integer.parseInt("25"));

      smtpOptions.setSMTPAuthenticationType(ISMTPOptions.CeSMTPAuthentication.LOGIN);

      smtpOptions.setSMTPUserName("username");

      smtpOptions.setSMTPPassword("password");

      smtpOptions.setSubject("Email subject");

      smtpOptions.setMessage("This is the email message.");

       

      

      //update TO address here

      List toAddresses = smtpOptions.getToAddresses();

      toAddresses.add("user1@emaildomain.com");

      toAddresses.add("user2@emaildomain.com");

      

      //update CC address here

      List ccAddresses = smtpOptions.getCCAddresses();

      ccAddresses.add("user1@emaildomain.com");

      ccAddresses.add("user2@emaildomain.com");

      

      destination.setFromPlugin(destinationPlugin);

      infoObject.save();

            

    }
Former Member
0 Kudos

Hi,

Thank you so much .

However, can you please help me in doing the same for Notifications, where we setup the success and failure notification, my requirement is to modify the email addresses of the notification as well.

I came across this thing called INotification but not enough sample codes on that.

Regards

MK

former_member230921
Active Contributor
DellSC
Active Contributor

You'll run a query to get the recurring schedules - Select * from CI_INFOOBJECTS where SI_INSTANCE = 1 and SI_SCHEDULE_STATUS = 9

For each IInfoObject in the list, you'll call .getSchedulingInfo() to get the ISchedulingInfo. Then you'll call .getDestinations() and call getName() for each IDestination in the list. If the name is "CrystalEnterprise.Smtp", this is a schedule to email. You'll then have to go through the properties of the IDestination to update SI_MAIL_ADDRESSES, SI_MAIL_CC, and SI_MAIL_BCC to update the addresses. When you're finished updating the addresses, you'll call .save() on the IInfoObject to save them to the CMS.

-Delll

Former Member
0 Kudos

Hi,

Thank you so much .

However, can you please help me in doing the same for Notifications, where we setup the success and failure notification, my requirement is to modify the email addresses of the notification as well.

I came across this thing called INotification but not enough sample codes on that.

Regards

MK

DellSC
Active Contributor

I haven't specifically worked with notifications, but here's what I would do:

1. Run a Query-Builder query that pulls all of the properties for one or more schedules that have notifications.

2. Look at the properties of the schedule - probably in the Scheduling Info - to find which ones contain notification information.

3. In your code, access the IProperties bag where you can get/set this information for the notifications.

4. Be sure to call .save() when you're finished updating each schedule.

-Dell