How do we pass newly created entitlement display name to a particular workgroup

Which IIQ version are you inquiring about?

Version 8.3

Share all details related to your problem, including any error messages you may have received.

Hi,
we have a requirement to get newly created entitlements display name and send that list to a specific workroup via mail.

As initial step , I created custom rule to get newly created entitlement display name in which I created a method to send that entitlement list to a specific workgroup.
My custom rule:
List entNm = new ArrayList();
String entlist=“”;

entNm.append("Entitlement Name : ");
ManagedAttribute ma = new ManagedAttribute();

QueryOptions qo = new QueryOptions();

Date last1DayDate = new Date();
last1DayDate= DateUtils.addDays(last1DayDate, -1);

qo.addFilter(Filter.gt(“created”,last1DayDate));// Filter to Get entitlements created in last 1 day
log.error (“qo list is :”+qo);
IncrementalObjectIterator<ManagedAttribute> managedAttrsIterator = new IncrementalObjectIterator<ManagedAttribute>(context, ManagedAttribute.class, qo);

while (managedAttrsIterator.hasNext()) {

ManagedAttribute managedAttr = (ManagedAttribute) managedAttrsIterator.next();
entNm.add(managedAttr.getDisplayName()); 

}
log.error (“getDisplayName:”+entNm);
entlist = entNm.toString();
return entlist;
sendNewAccountEmail(entlist);

public void sendNewAccountEmail(String entlist){
EmailTemplate template = context.getObjectByName(EmailTemplate.class, “New Entitlement Notification”);
EmailOptions options = new EmailOptions();
String workgroupName = “Certification Administrator”;
Identity workgroup = context.getObjectByName(context, workgroupName);
List emails = sailpoint.api.ObjectUtil.getEffectiveEmails(context, workgroup);
Identity managerIdentity = identity.getManager();
options.setTo(emails);
Map args = new HashMap();
args.put(“entlist”, entlist);
options.setVariables(args);
context.sendEmailNotification(template,options);

  }

Secondly , I created dummy email template to refer the entitlements list

<?xml version='1.0' encoding='UTF-8'?>
  &lt;html>
  &lt;body>
  
  
  Please find below the new entitlements 
  &lt;p>
  New Entitlement added: $entlist
  &lt;br/>
 
  ***Please do not reply to this email because this is an outgoing mailbox only. Thanks.***

  ****************************************************************************************************
  
  &lt;/p>
  &lt;br/>
  &lt;/body>
  &lt;/html>
New Entitlement Notification New Entitlement Notification

Thirdly, I ran a task definition where I referred this custom rule.
But for some reason email is not getting trigerred and I dont get any errors.

Can someone suggest what I am missing in the code. Any suggestions will be helpfull.

Thanks!

Hi Preethi,
There’s actualy no need to have separate task for that - there are 2 options how you can do that.

  1. You can create customization rule where you’ll send email when new entitlement is detected
    image
  2. You can also create group refresh rule to detect if the group already exists or not and then send email.

This is good solution for entitlements which you aggregate.

If you are creating entitlements via LCM workflows than I would rather add notification into that workflow.

Regarding your code and your solution:
I would check 2 things first (would be great if you could add screenshots)

  1. Go to Global Settings → IdentityIQ Configuration and check SMTP configuration
    image

if it is correct.
2. Check how is the workgroup notification configured
image

as getEffectiveEmails method relies on this setting

Hi kamil,
Please find below

We have email settings set to SMTP/Basic and necessary configurations. We will be using mailtrap to check out test email.

Hi @Preethi,

You can try using below Rule and Email Template which are slightly changed from yours.

Rule :

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;

import sailpoint.api.IncrementalObjectIterator;
import sailpoint.api.SailPointContext;
import sailpoint.object.EmailOptions;
import sailpoint.object.EmailTemplate;
import sailpoint.object.Filter;
import sailpoint.object.Identity;
import sailpoint.object.ManagedAttribute;
import sailpoint.object.QueryOptions;
import sailpoint.tools.GeneralException;

  public void sendNewAccountEmail(List entlist) throws GeneralException {
    EmailTemplate template = context.getObjectByName(EmailTemplate.class, "New Entitlement Notification");
    EmailOptions options = new EmailOptions();
    String workgroupName = "Certification Administrator"; // Workgroup Name
    Identity workgroup = context.getObjectByName(Identity.class, workgroupName);
    List email = sailpoint.api.ObjectUtil.getEffectiveEmails(context, workgroup);
    options.setTo(email);
    Map args = new HashMap();
    args.put("entitlements", entlist);
    options.setVariables(args);
    context.sendEmailNotification(template, options);

  }
  
  
  List entitlements = new ArrayList();

  QueryOptions qo = new QueryOptions();
  Date last1DayDate = new Date();
  last1DayDate = DateUtils.addDays(last1DayDate, -1);
  qo.addFilter(Filter.gt("created", last1DayDate));// Filter to Get entitlements created in last 1 day
  IncrementalObjectIterator managedAttrsIterator = new IncrementalObjectIterator(context, ManagedAttribute.class, qo);
  while (managedAttrsIterator.hasNext()) {
    ManagedAttribute managedAttr = (ManagedAttribute) managedAttrsIterator.next();
    if(managedAttr.getDisplayName() != null ){
      entitlements.add(managedAttr);
    }
  }

  if (!entitlements.isEmpty()) {
    sendNewAccountEmail(entitlements);
  }

Email Template :

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE EmailTemplate PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<EmailTemplate name="New Entitlement Notification">
  <Body>
    &lt;html>
      &lt;head>
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      &lt;/head>
      &lt;body>
        Please find below the new entitlements &lt;br/>&lt;br/>
        List of New Entitlements Created: &lt;br/>&lt;br/>
        &lt;table width="30%" cellpadding="2" border="1" style="border-collapse:collapse">
          &lt;tr>
            &lt;th align="left" >Entitlement Display Name&lt;/th>
            &lt;th align="left" >Application Name&lt;/th>
              #if($!entitlements)
                #foreach($entitlement in $entitlements )
                  &lt;tr>
                    &lt;td>$entitlement.DisplayName&lt;/td>
                    &lt;td>$entitlement.Application.name&lt;/td>
                  &lt;/tr>
                #end
              #end
        &lt;/table>
        &lt;br/>
        Thanks &lt;br/>
        SailPoint Team &lt;br/>&lt;br/>
        
        
        ***Please do not reply to this email because this is an outgoing mailbox only.***&lt;br/>
        *********************************************************************************
        &lt;br/>
      &lt;/body>
    &lt;/html>
  </Body>
  <Description>
      Email template used to notify of new entitlements.
    </Description>
  <Signature>
    <Inputs>
      <Argument name="entitlements" type="ArrayList">
        <Description>The List of entitlements created.</Description>
      </Argument>
    </Inputs>
  </Signature>
  <Subject>List of Entitlements created Last Day</Subject>
</EmailTemplate>

Hi @Jarin_James ,

Code is working fine. Thank you for the update.

Thanks!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.