Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Conditional based mail template

NikitaPawar_
New Contributor II
New Contributor II

Hello,
I'm encountering an issue with a business-related use case. Here's the scenario: "If the beneficiary's Custom Property 10 is set to 'Salary', an email should be sent to payroll@xyz.com notifying them that access has been added for this user."

I attempted to implement this using a condition in the "TO" field of the email template, but unfortunately, it didn't work as expected. Here's what I tried:

  1. <% if ($user?.customproperty10 == "Salary") print "payroll@xyz.com" else if ($user?.customproperty10 == "Hourly") print "nikita@xyz.com" %>

  2. <% if (${task?.userkey.customproperty10 == "Salary") print "payroll@xyz.com" else if (${task?.userkey.customproperty10 == "Hourly") print "nikita@xyz.com" %>

I also have a couple of questions:

  1. Is it necessary to format the entire email template in HTML when specifying the "TO" field in HTML form?

Will the condition written in the email template be readable at the endpoint level? Like, if we attach the conditional based email template at the endpoint level and it triggers after the completion of an "add account/access" task, will the email template detect users with Custom Property 10 set to "Salary" based on condition and send emails only to them based on this trigger?

Looking forward to your response.
Thank you!
Nikita Pawar

[This post has been edited by a Moderator. We discourage the @ mention of other forum users or employees unless they have already involved themselves on the forum post.]

3 REPLIES 3

rushikeshvartak
All-Star
All-Star

Email variables change based on where email template is attached.

To get what variables are present to use in the email template, check using the below expression. By putting it in the email body, it will print all variable names with values, and then accordingly, you can use it:


${this.binding.variables.each {k,v -> println "$k = $v" + "" + "br" + ">"}}

 

Please confirm where email template is attached


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

Raghu
Valued Contributor III
Valued Contributor III

@NikitaPawar_  try below

<% if (null!=user.customproperty10 && user.customproperty10 == "Salary") print "payroll@xyz.com" else if (null!=user.customproperty10 && user.customproperty10 == "Hourly") print "nikita@xyz.com" %>

 


Thanks,
Raghu
If this reply answered your question, Please Accept As Solution and hit Kudos.

Manu269
All-Star
All-Star

@NikitaPawar_ refer this post :

How to send different emails with if else conditio... - Saviynt Forums - 51043

Syntax for email template body - Saviynt Forums - 56535

Regards
Manish Kumar
If the response answered your query, please Accept As Solution and Kudos
.