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

Select statement in "to" field of email template

Tezinder
New Contributor
New Contributor

Can we use select statement in "to" field of email templates along with if else?

I am trying to use this basic select query to find the user email uniqueness and if it is unique then user.email should be returned or else manager.email

<%if ((select count(email) from users where email LIKE user.email) <= 1) print "${user.email}" else print "${manager.email}" %>

I am getting the below error:

2024-06-13T15:53:53-05:00-ecm-worker-changeaction.UserChangeActionService-quartzScheduler_Worker-2-8ngfw-ERROR-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:
 
2024-06-13T15:53:54-05:00-ecm-worker--null-8ngfw--1 error
 
2024-06-13T15:53:54-05:00-ecm-worker--null-8ngfw--groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
 
2024-06-13T15:53:54-05:00-ecm-worker--null-8ngfw--1 error
 
2024-06-13T15:53:53-05:00-ecm-worker-changeaction.UserChangeActionService-quartzScheduler_Worker-2-8ngfw-DEBUG-NEW RULEACTIONFAILED = {"actionName":"Notify As An Email","ruleName":"test rule for email template","ruleKey":143,"actionFields":{"emailTemplate":"test language"},"failureReason":"Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:\nSimpleTemplateScript7.groovy: 1: expecting ')', found 'count' @ line 1, column 31.\n out.print(\"\"\"\"\"\");if ((select count(email) from users where email LIKE user.email) <= 1) print \"${user.email}\" else print \"${manager.email}\" ;\n ^\n\n1 error\n"}
 
Can anyone help?
3 REPLIES 3

rushikeshvartak
All-Star
All-Star

SQL query are not supported in email template.

Please confirm your requirement to provide workaround


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

Here is the requirement for to field of email template:

Check if user's email is unique. If unique then set TO field to user's email and not unique then set manager's email in to field.

Uniqueness needs to be checked against sav user's email

This is not supported to check unique email against users list.


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