Role Owner Termination Workflow Email Template Velocity Not Working

Having a rough time figuring out how to render a single role owned by a terminated user in the email template using Velocity. If there are multiple roles owned, then this velocity works:

    #foreach ($rolename in ${rolenames})
  • $rolename
  • #end
#end

However, if there is only a single role owned then it never renders.
I am attaching the workflow for review. I am really hoping someone can point me in the right direction! Thanks.
RoleOwnerTerminationWorkflow20231031.json (2.8 KB)

Your $rolenames variable is probably coming in as a String, not a List containing a single string.

You could try adding some logic to check the size like:

#if ($rolenames.size() > 1)
#foreach ($rolename in $rolenames)
$rolename
#end
#else
$rolenames
#end

You might also be able to check the object class of your variable. I haven’t tested this, but something like this might work:

#if ($rolenames.class.name == "java.lang.String")
$rolenames
#else
#foreach ($rolename in $rolenames)
$rolename
#end
#end
1 Like

The second approach worked. Thank you so much for this.

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