Add IF Else Condition in the To part of Email Templates

New Contributor III
New Contributor III

In the email template, to address I need to write conditional logic where a particular group suppose should be notified with email only if the requestor raises the request for those entitlements that starts with ERP.


I had tried below expression in to part part but the email is not triggering.


<% if (entitlement_value in ('ERP_BAC_Analytics','ERP_ABC_Analytics','ERP_XYZ_Analytics') and (entitlementtypekey=25 and status=1)) print "" %>


This above expression is throwing the below error:

{"log":"2022-09-01 14:56:56,152 [quartzScheduler_Worker-3] ERROR services.ArsTaskService - Error while sending email - Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:\n","stream":"stdout","time":"2022-09-01T14:56:56.152328562Z"}


Can any one please suggest how can I acheive it?

NOTE: I am triggering this email in the ENDPOINT level for Add Access and Task completion.



Can you try below



Hi rushikesh,

I tried with your given query but the mail is not triggering.

The below way I tried in To part of email.

<% if ${entitlement_values.collect{it.toString()}.toListString().replaceAll('\\[|\\]','').startsWith('ERP_')} print ""%>

Can you please help me out with any other alternative approach.

<% if (entitlement.replaceAll('\\[|\\]','').contains('ERP_')) print ""%>






Saviynt Employee
Saviynt Employee


We can only use groovy/string functions and methods in email templates. 'IN' is not a function/method for groovy/java which is why you see the message.

Use a method like contains.

Sahaj Ranajee
Sr. Product Specialist

New Contributor III
New Contributor III

Hi Sahaj,

Can you please suggest for the requirement what function should we use?


Did you tried solution shared above?