Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • May 07 at 09:27 AM

    Check for "Set destination to SMTP":

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

    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();
    
                
    
        }
    
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • May 09 at 06:19 AM

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

    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;
                 }
                 
             }
    Add comment
    10|10000 characters needed characters exceeded

    • 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");
  • May 04 at 02:05 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • May 09 at 05:13 AM
    Add comment
    10|10000 characters needed characters exceeded