Add Identity Attribute to Workflow SendEmail Step

We are on IIQ 8.3

Not a developer, but still trying to learn little by little. I have a step in my workflow to send an email notification and it works fine. I want to add a couple of Identity Attributes to the email. Here is the workflow step -

  <Step action="call:sendEmail" icon="Email" name="Send Email">
    <Arg name="template" value="Leave of Absence Return Email Template"/>
    <Arg name="cc"/>
    <Arg name="identityDisplayName" value="ref:identityDisplayName"/>
    <Arg name="bcc"/>
    <Arg name="identityName" value="ref:identityName"/>
    <Arg name="subject" value="Return from Leave of Absence Notification"/>
    <Arg name="from" value="[email protected]"/>
    <Arg name="identityRequestId"/>
    <Arg name="to" value="[email protected]"/>
    <Transition to="End"/>
  </Step>

I tried adding something like this to the workflow -

<Variable initializer="script:identity.getAttribute(&quot;team&quot;); " name="identityTeam"/>

and am trying to reference it in the emailTemplate like this -

Users Team: $!{identityTeam}

I see this in the logs -

Caused by: org.apache.bsf.BSFException: BeanShell script error: bsh.EvalError: Sourced file: inline evaluation of: ``identity.getAttribute("team");'' : Attempt to resolve method: getAttribute() on undefined variable or class name: identity : at Line: 1 : in file: inline evaluation of: ``identity.getAttribute("team");'' : identity .getAttribute ( "team" )

Any and all assistance truly appreciated!

It’s saying that there’s no identity variable in the place you’re doing script:identity.getAttribute(&quot;team&quot;). Generally, only the name or id of SailPointObjects get passed around workflows, so this seems correct to me that it’d throw that error.

What you could do instead is pull that data inside of the email template like this using the identityName variable that’s already being passed in:

<EmailTemplate name="TestEmail">

  <Body>

#set($spctx=$spTools.class.forName("sailpoint.api.SailPointFactory").getMethod("getFactory", null).invoke(null, null).getCurrentContext())

 

#set($identity=$spctx.getObjectByName($spTools.class.forName("sailpoint.object.Identity"), $identityName))

 

Identity Name from context: ${identity.firstname} ${identity.lastname}

Identity Department from context: ${identity.department}

Users Team: $!{identity.team}

 

  </Body>

  <Description>Email Template</Description>

  <Subject>Test Email Template</Subject>

</EmailTemplate>

https://community.sailpoint.com/t5/Technical-White-Papers/Email-Template-Arguments/ta-p/73115#toc-hId--1482251534

Near the bottom of this page is where it warns against passing objects directly in workflows:

https://community.sailpoint.com/t5/Technical-White-Papers/BSDG-16-Workflow-Step-Bean-Shell-Best-Practices/ta-p/73229

1 Like

Thank you @drardin !! Really appreciate it.

Got much closer now!

I’ll read over the links you sent and see if I can figure more out, thanks for those!

I added this to the email template -

<Body>
  
#set($spctx=$spTools.class.forName("sailpoint.api.SailPointFactory").getMethod("getFactory", null).invoke(null, null).getCurrentContext())
 
#set($identity=$spctx.getObjectByName($spTools.class.forName("sailpoint.object.Identity"), $identityName))
    
    <p> TESTING EMAIL ARGUMENTS </p>
    
     <p>Identity Name from context: ${identity.firstname} ${identity.lastname}</p>

	<p>Identity Department from context: ${identity.department}</p>

	<p>Users Team: ${identity.team}</p>
    
    <p>Users Location: ${identity.location}</p>
    <p>Users recordStatus: ${identity.recordStatus}</p>
    <p>Users title: ${identity.title}</p>
    <p>Users employeeType: ${identity.employeeType}</p>
    <p>Users businessUnit: ${identity.businessUnit}</p>
</Body>

These are the attributes on the Identity Cube -

  <Attributes>
    <Map>
      <entry key="IIQLifecycleStatus" value="JoinerProcessed"/>
      <entry key="businessUnit" value="Corporate"/>
      <entry key="department" value="Cloud Services"/>
      <entry key="displayName" value="SPTest One"/>
      <entry key="email" value="[email protected]"/>
      <entry key="employeeId" value="98917"/>
      <entry key="employeeType" value="Employee"/>
      <entry key="firstname" value="SPTest"/>
      <entry key="lastname" value="One"/>
      <entry key="location" value="Santa Barbara"/>
      <entry key="recordStatus" value="Leave"/>
      <entry key="startDate" value="1/15/2025 12:00:00 AM"/>
      <entry key="status" value="Active"/>
      <entry key="team" value="Cloud Security"/>
      <entry key="title" value="Security Analyst"/>
      <entry key="userName" value="sg98917"/>
    </Map>
  </Attributes>

This was the result -

  
  TESTING EMAIL ARGUMENTS 
Identity Name from context: SPTest One
Identity Department from context: ${identity.department}
Users Team: ${identity.team}
Users Location: ${identity.location}
Users recordStatus: ${identity.recordStatus}
Users title: ${identity.title}
Users employeeType: ${identity.employeeType}
Users businessUnit: ${identity.businessUnit}

First Name and Last Name worked great, the rest don’t seem to find anything.

I’ll keep researching, if you or anyone have any ideas please let me know, thanks again.

It seems you may not be able to access the other extended attributes in the same way as first name and last name. You can try below which should work fine.

<Body>
  
#set($spctx=$spTools.class.forName("sailpoint.api.SailPointFactory").getMethod("getFactory", null).invoke(null, null).getCurrentContext())
 
#set($identity=$spctx.getObjectByName($spTools.class.forName("sailpoint.object.Identity"), $identityName))
    
    <p> TESTING EMAIL ARGUMENTS </p>
    
     <p>Identity Name from context: ${identity.firstname} ${identity.lastname}</p>

	<p>Identity Department from context: ${identity.getStringAttribute("department")}</p>

	<p>Users Team: ${identity.getStringAttribute("team")}</p>
    
    <p>Users Location: ${identity.getStringAttribute("location")}</p>
    <p>Users recordStatus: ${identity.getStringAttribute("recordStatus")}</p>
    <p>Users title: ${identity.getStringAttribute("title")}</p>
    <p>Users employeeType: ${identity.getStringAttribute("employeeType")}</p>
    <p>Users businessUnit: ${identity.getStringAttribute("businessUnit")}</p>
</Body>
1 Like

Thank you both so much, I love the amazing people on this forum!

I ended up with a bit of a mixture of both and some things from other posts I found -

#set($spctx=$spTools.class.forName("sailpoint.api.SailPointFactory").getMethod("getFactory", null).invoke(null, null).getCurrentContext())
 
#set($identity=$spctx.getObjectByName($spTools.class.forName("sailpoint.object.Identity"), $identityName))
    
#set($identityDept = $identity.getAttribute("department"))
    #set($identityTeam = $identity.getAttribute("team"))
    #set($identityLocation = $identity.getAttribute("location"))
    #set($identityRecordStatus = $identity.getAttribute("recordStatus"))
    #set($identityTitle = $identity.getAttribute("title"))
    #set($identityEmployeeType = $identity.getAttribute("employeeType"))
    #set($identityBusinessUnit = $identity.getAttribute("businessUnit"))

     <p>Identity Name from context: ${identity.firstname} ${identity.lastname}</p>
	<p>Identity Department from context: ${identityDept}</p>
	<p>Users Team: ${identityTeam}</p>
    <p>Users Location: ${identityLocation}</p>
    <p>Users recordStatus: ${identityRecordStatus}</p>
    <p>Users title: ${identityTitle}</p>
    <p>Users employeeType: ${identityEmployeeType}</p>
    <p>Users businessUnit: ${identityBusinessUnit}</p>


This worked perfectly!

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