Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Add IF Else Condition in the To part of Email Templates

Souvik
New Contributor III
New Contributor III

In the email template, to address I need to write conditional logic where a particular group suppose XYZ@gmail.com 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 "XYZ@gmail.com" %>

 

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.

6 REPLIES 6

rushikeshvartak
All-Star
All-Star

Can you try below

${entitlement_values.collect{it.toString()}.toListString().replaceAll('\\[|\\]','').startsWith('ERP_')}

 


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

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 "XTZ@gmail.com"%>

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

<% if (entitlement.replaceAll('\\[|\\]','').contains('ERP_')) print "rvartak@gmail.com"%>
 
rushikeshvartak_2-1662394039799.png

 


 

rushikeshvartak_1-1662393974799.png

 

 


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

sahajranajee
Saviynt Employee
Saviynt Employee

@Souvik 

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.


Regards,
Sahaj Ranajee
Sr. Product Specialist

Souvik
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? 


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.