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

Email template customization - Use of VTL list, comparison, and loop

Email template customization - Use of VTL list, comparison, and loop

This is a customization of OOTB - "LCM Identity Update Approval". Basically we need to group requested entitlements by application.

 

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!DOCTYPE EmailTemplate PUBLIC "sailpoint.dtd""sailpoint.dtd"
  3. <EmailTemplate name="LCM Identity Update Approval"
  4.   <Body><![CDATA[ <html><font size="3" face="arial"
  5.  
  6. #set ( $spctx = $spTools.class.forName("sailpoint.api.SailPointFactory").getMethod("getFactory", null).invoke(null, null).getCurrentContext() )   
  7. #set ( $identity = $spctx.getObjectByName($spTools.class.forName("sailpoint.object.Identity"), $identityName) ) 
  8. #set ( $launcherIdentity = $spctx.getObjectByName($spTools.class.forName("sailpoint.object.Identity"), $launcher) ) 
  9.  
  10. $item.Owner.DisplayName, <p> 
  11.  
  12. You have received an access change request for $identityDisplayName (${identity.getAttribute("JOB_TITLE")}), who reports to ${identity.Manager.DisplayName}  in the ${identity.getAttribute("DEPT_NAME")} department. <p> 
  13.  
  14. The following systems access changes were requested on $spTools.formatDate($item.Created, "MMM d, yyyy") for ${identityDisplayName} by $launcherIdentity.DisplayName and require your approval.<p> 
  15.  
  16.  
  17. #if ( $approvalSet.items ) 
  18.  
  19. #set ($approvalSetScanned = [] ) 
  20.  
  21. #foreach ($approvalItem in $approvalSet.items) 
  22.   #if ( !$approvalSetScanned.contains($approvalItem.id) ) 
  23.  
  24.         Application: $approvalItem.applicationName <br> 
  25.  
  26.   #if ( $approvalItem.nativeIdentity )  
  27.   #set ($args = { 'userPrincipalName': ${identity.getAttribute("userPrincipalName")} }) 
  28.       #set ($rule = $spctx.getObjectByName($spTools.class.forName("sailpoint.object.Rule"), 
  29. "Get-AD-sAMAccountName")) 
  30.       #if ( $spctx.runRule($rule, $args) ) 
  31.             Account ID: $spctx.runRule($rule, $args) <br> 
  32.       #else
  33.         Account ID: $approvalItem.nativeIdentity <br> 
  34.   #end 
  35.  
  36.   #end       
  37.  
  38.   #foreach ($subApprovalItem in $approvalSet.items) 
  39.   #if ( !$approvalSetScanned.contains($subApprovalItem.id) && $approvalItem.applicationName == $subApprovalItem.applicationName) 
  40.  
  41.   #set ( $result = $approvalSetScanned.add($subApprovalItem.id) ) 
  42.  
  43.         Operation: $subApprovalItem.operation <br>      
  44.  
  45.   #if ( $subApprovalItem.displayValue ) 
  46.                          Role or Group Name: $subApprovalItem.displayValue <br> 
  47.   #elseif ( $subApprovalItem.csv ) 
  48.                          Role or Group Name: $subApprovalItem.csv <br> 
  49.   #end 
  50.  
  51.   #set ($args = { 'entitlement': $subApprovalItem.csv,     
  52. 'appName':$subApprovalItem.ApplicationName }) 
  53.       #set ($rule = $spctx.getObjectByName($spTools.class.forName("sailpoint.object.Rule"), 
  54. "Get-Entitlement-Desc")) 
  55.       #if ( $spctx.runRule($rule, $args) )       
  56.                Role or Group Desc: $spctx.runRule($rule, $args) <br> 
  57.   #end 
  58.  
  59.   #if ( $subApprovalItem.requesterComments ) 
  60.                Comments: $subApprovalItem.requesterComments <br> 
  61.   #end 
  62.   <p> 
  63.  
  64.   #end 
  65.  
  66.   #end 
  67.  
  68.   #end 
  69.  
  70. #end 
  71.  
  72. #end 
  73.  
  74.   </font></html> 
  75.   ]]> </Body> 
  76.   <Description> 
  77.       Email Template for notifying approvers when they need to approve a request made through LCM. 
  78.       Note that in addition to the declared arguments, all workflow variables, 
  79.       Step arguments, and Approval arguments defined in the Workflow are 
  80.       also available. 
  81.     </Description> 
  82.   <Signature> 
  83.     <Inputs> 
  84.       <Argument name="workflow" type="Workflow"
  85.         <Description>The Workflow object being executed.</Description> 
  86.       </Argument> 
  87.       <Argument name="item" type="WorkItem"
  88.         <Description>The WorkItem representing the review.</Description> 
  89.       </Argument> 
  90.       <Argument name="approvalSet" type="ApprovalSet"
  91.         <Description>The ApprovalSet object contained in the work item.</Description> 
  92.       </Argument> 
  93.       <Argument name="launcher" type="string"
  94.         <Description>The name of the Identity that launched the workflow.</Description> 
  95.       </Argument> 
  96.       <Argument name="identityName" type="string"
  97.         <Description>The name of the Identity that is being changed.</Description> 
  98.       </Argument> 
  99.       <Argument name="identityDisplayName" type="string"
  100.         <Description>The display name of the Identity that is being changed.</Description> 
  101.       </Argument> 
  102.     </Inputs> 
  103.   </Signature> 
  104.   <Subject>Changes requested for $identityDisplayName require approval</Subject> 
  105. </EmailTemplate> 
Labels (2)
Version history
Revision #:
2 of 2
Last update:
‎Jun 23, 2023 12:44 PM
Updated by: