cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to disable work item reminders/escalations in a task?

How to disable work item reminders/escalations in a task?

This task was developed to remove certifier from delegation reminders. For example, in a manager certification campaign with access reviews delegated to his/her direct reports, reminders would go to both the manager and direct reports. In the case of manager not wanting the reminders, run this task to disable it.

 

Import this rule and create a "Run Rule" task that points to the rule. In the rule config of the task, provide this as input argument: CertificationGroupID,ff808081552c2b0d01553143c01f07f2

The CertificationGroup id can be found in Debug.

 

If you want to integrate this to be part of the certification campaign, you can put the logic below in a workflow and schedule it in your certification's Active Period Enter Rule (Rule type="CertificationPhaseChange"). Please read this white paper for how to Scheduling a Workflow to run in the future from BeanShell / Rule code.

 

  1. <?xml version='1.0' encoding='UTF-8'?> 
  2. <!DOCTYPE Rule PUBLIC "sailpoint.dtd""sailpoint.dtd"
  3. <Rule language="beanshell" name="Disable Reminder Rule"
  4.   <Source> 
  5.     <![CDATA[ 
  6.  
  7.  
  8. import org.apache.log4j.Logger; 
  9. import org.apache.log4j.Level; 
  10.  
  11.  
  12.  
  13. import sailpoint.api.ObjectUtil; 
  14.  
  15.  
  16. import sailpoint.object.Identity; 
  17. import sailpoint.object.Certification; 
  18. import sailpoint.object.CertificationGroup; 
  19. import sailpoint.object.CertificationEntity; 
  20. import sailpoint.object.CertificationDelegation; 
  21. import sailpoint.object.AbstractCertificationItem; 
  22. import sailpoint.object.NotificationConfig; 
  23. import sailpoint.object.NotificationConfig.IConfig; 
  24. import sailpoint.object.WorkItem; 
  25. import sailpoint.object.Filter; 
  26. import sailpoint.object.QueryOptions; 
  27. import sailpoint.tools.Util; 
  28.  
  29.  
  30. Logger log = Logger.getLogger("sailpoint.services.rule.myrule"); 
  31. log.setLevel(Level.DEBUG);   
  32. log.debug("myrule" + config.get("CertificationGroupID")); 
  33.  
  34.  
  35. QueryOptions ops = new QueryOptions(); 
  36. ops.add( Filter.eq( "certificationGroups.id", CertificationGroupID)); 
  37. Iterator iterator = context.search( Certification.class, ops ); 
  38.  
  39.  
  40. // Iterate through access reviews
  41. while (iterator != null && iterator.hasNext()) { 
  42.     Certification cert = (Certification) iterator.next(); 
  43.     log.debug("Looking into cert: " + cert.getName()); 
  44.  
  45.     List certifiers =  cert.getCertifiers(); 
  46. if (certifiers != null) { 
  47. // The certifying manager is always the first (0) certifier.
  48.         String certifier = certifiers.get(0); 
  49.         List certWIs = cert.getWorkItems(); 
  50.  
  51. if (certWIs != null) {     
  52. // Iterate through the associated work items.
  53. for (WorkItem wi : certWIs) {       
  54.                 Identity notifyOwner = (Identity) wi.getNotificationOwner(context); 
  55.  
  56. // Check the current work item to see if it is meant for the certifying manager
  57. if ((notifyOwner != null) && notifyOwner.getName().equals(certifier)) { 
  58.                     NotificationConfig nConfig = wi.getNotificationConfig(); 
  59. if ((nConfig != null) && (nConfig.getConfigs() != null)) { 
  60.                         List subConfigs = nConfig.getConfigs(); 
  61.                         Iterator sConfigsIter = subConfigs.iterator(); 
  62.  
  63. while (sConfigsIter.hasNext()) { 
  64.                             NotificationConfig.IConfig iConfig = sConfigsIter.next(); 
  65.  
  66. // Find the target email template
  67. if (iConfig.getEmailTemplateName().equals("my template name") && iConfig.isEnabled()) { 
  68. if (!ObjectUtil.isLockedById(context, WorkItem.class, wi.getId())) {     
  69. try
  70. // Mark the target email template as disabled for the work item that belongs to the certifying manager
  71.                                               iConfig.setEnabled(false); 
  72.  
  73. // Change the next wakeup date to next reminder if there is any
  74.  
  75. if( sConfigsIter.hasNext() ) {                                                   
  76.                                                   NotificationConfig.IConfig nextIConfig = sConfigsIter.next(); 
  77. long launchTime = wi.getWakeUpDate().getTime() + ( nextIConfig.getMillis() - iConfig.getMillis() ); 
  78.                                                   wi.setWakeUpDate(new Date(launchTime)); 
  79.                                               } 
  80.  
  81.                                           context.saveObject(wi); 
  82.                                         context.saveObject(cert); 
  83.                                        } finally
  84.                                            context.commitTransaction(); 
  85.                                            log.debug( "Successfully disabled " + certifier ); 
  86.                                        }  
  87.                                    } // end lock work item
  88.                                   }// end email template name match
  89.                               } // end subConfigs loop
  90.                           } // end config null check
  91.                  } // end notifyOwner null check
  92.              } // end work item loop
  93.            } // end certWIs null check 
  94.   } // end certifiers null check 
  95. } // end iterator
  96. Util.flushIterator(iterator); 
  97.  
  98.  
  99. return"Success";     
  100.  
  101.  
  102.  
  103.     ]]> 
  104.   </Source> 
  105. </Rule> 
Labels (1)
Version history
Revision #:
2 of 2
Last update:
‎Jul 26, 2023 05:22 PM
Updated by: