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

If else condition is not working in email template

saimeghana
Regular Contributor II
Regular Contributor II

Hi Team,

We are using the if else condition in "TO address" and this condition is not working.

Issue: if user1 is having the entity value and user2 entity value is Null still this email is triggering for both the users.

Tried with below conditions:

<% if (user.entity=='WW SuccessFactors' ) print"abc@abc.com" else print "xyz@abc.com" %>

<% if (user?.entity=='WW SuccessFactors' ) print"abc@abc.com" else print "xyz@abc.com" %>

Please help us to resolve this issue.

Regards,

Sai Meghana

11 REPLIES 11

Raghu
Valued Contributor III
Valued Contributor III

try like below

<% if (null!=user.entity && user.entity=='WW SuccessFactors' ) print"abc@abc.com" else print "xyz@abc.com" %>


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

rushikeshvartak
All-Star
All-Star

Please explain what should be expected behavior ?

 
<% if (null!=user.entity && user.entity.equalsIgnoreCase('WW SuccessFactors') ) print"abc@abc.com" else print "xyz@abc.com" %>
  • null!=user.entity: This condition checks if user.entity is not null. If it's not null, it proceeds to the next part of the condition.

  • user.entity.equalsIgnoreCase('WW SuccessFactors'): This part checks if the user.entity string, when converted to lowercase (using equalsIgnoreCase), is equal to "WW SuccessFactors". This is a case-insensitive comparison


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

saimeghana
Regular Contributor II
Regular Contributor II

Hi Rushikesh,

We tried with both the solutions but still, we are facing the issue.

We are using Change password as task type

Expected Output: For which user entity condition matches it should trigger email only for that user but it is triggering for all the users.

TO: <% if (null!=user.entity && user.entity.equalsIgnoreCase('WW SuccessFactors') && null!=user.customproperty6 && user.customproperty6!=' ' && user.manager!=' ' && null!=user.manager) print"${manager.email}" else if (user.entity=='WW SuccessFactors' && user.entity.equalsIgnoreCase('WW SuccessFactors') && null!=user.customproperty16 && user.customproperty16!=' ') print "${user.customproperty16}" %>

can you share

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" + ">"}}

 

also check {user?.entity}


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

Hi Rushikesh,

Please help me below is my output for the expression.

entitlement_endpoint_list = []br> manager = abc> service_accounts_list = []br> ownerOnTerminate = abc> serviceaccount_endpoints_list = []br> baseUrlForEmail = https://release-n-plus-one.saviyntcloud.com/ECMbr> user = ahsavtest.user0518br> requestor = abc> entitlement_value_list = []br> out = java.io.PrintWriter@2d3a4116br> [entitlement_endpoint_list:[], manager:abc, service_accounts_list:[], ownerOnTerminate:abc, serviceaccount_endpoints_list:[], baseUrlForEmail:https://release-n-plus-one.saviyntcloud.com/ECM, user:ahsavtest.user0518, requestor:abc, entitlement_value_list:[], out:java.io.PrintWriter@2d3a4116]

Regards,

Sai Meghana

TO: <% if (null!=user?.entity && user?.entity.equalsIgnoreCase('WW SuccessFactors') && null!=user?.customproperty6 && user?.customproperty6!=' ' && user?.manager!=' ' && null!=user?.manager) print"${manager.email}" else if (user?.entity=='WW SuccessFactors' && user?.entity.equalsIgnoreCase('WW SuccessFactors') && null!=user?.customproperty16 && user?.customproperty16!=' ') print "${user?.customproperty16}" %>

 


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

Hi Rushikesh,

We tried with above condition now email are not triggered to our mailbox.

Regards,

Sai Meghana

Validate if above condition works in EMail body or not


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

krunalkadam
New Contributor III
New Contributor III

Could you please print user.entity and confirm the value it is returning?

saimeghana
Regular Contributor II
Regular Contributor II

Hi Krunal,

It is printing the entity value in Email Body.

Regards,

Sai Meghana

Raghu
Valued Contributor III
Valued Contributor III

@krunalkadam  multiple condition not working already i tried, end of done different template

check below article

https://forums.saviynt.com/t5/identity-governance/email-templte-to-recipe-logic/td-p/79033

please contact saviynt team may be they will help have any alternative


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