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

Add if else in To email templates

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on October 13 2021 at 09:15 UTC

In the email templates, to address i need to write conditional logic like If manager?.email!=null print "xyz@abc.com" else print "cde@abc.com" . I tried below example but not working



<% if ((manager.email != null)) print "${manager.email}" else print "axy@abc.com" %>


<% if ((manager?.email != null)) print "${manager?.email}" else print "xyz@abc.com" %>


any suggestions?

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.
8 REPLIES 8

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on October 13 2021 at 13:35 UTC

Hi,


See if this helps.


<% if (requesttype == 'Add') print "Add Role" else if (requesttype == 'Remove') print "Remove Role" else if (requesttype == 'New Account') print "New Account" else if (requesttype == 'Remove Account') print "Remove Account" else if (requesttype == 'Modify Account') print "Modify Account" %>


Thanks,

Pallavi Chaudhari

Persistent Systems Ltd.

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on October 13 2021 at 15:58 UTC

i am trying to use this in email template,


image



can you help me how to use this here?

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on October 13 2021 at 16:06 UTC

Hi,


Here's another example below.


<% if (null!=user.email && user.email!='') print"${user.email}" else print"${user.secondaryEmail}" %>


You can find more examples/samples in the documentation  : https://saviynt.freshdesk.com/a/solutions/articles/43000622153



Note: I would suggest you to mask the customer information when posting screenshots.



Regards,

Avinash Chhetri

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on October 13 2021 at 18:13 UTC

Hello, i also tried to use conditionals but it seems that it errors out and doesnt send out the email for me 

All i want to do is a If statement. This is the exact statement that i used with the <% and the %> in the template. It doesnt seem to compile properly and the email never gets sent.

<% if ${task?.tasktype} ==3) print "Hello" %>

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on October 14 2021 at 23:32 UTC

Patrick,


For your use case, try the following logic in your "To" list (just update the email address) :


${if(tasktype.equalsIgnoreCase('NewAccount')){'abc@xyz.com'} else {'xyz@abc.com'}}




Regards,

Avinash Chhetri

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 15 2021 at 11:13 UTC

I tried below condition in Body but it is not working could you help



<% if (user.employeeclass != null)

 print "Dear ${user.firstname} ${user.lastname},</div><div>&nbsp;</div><div>A new user account has been created for employee ${user.firstname} ${user.lastname}</div><div>&nbsp;</div><div><b>


 Username:</b> ${user.systemUserName}</div><div><br></i></div>"


 else  print "Dear ${user.firstname} ${user.lastname},</div><div>&nbsp;</div><div>Access has been granted for below request:</div><div>&nbsp;</div><div>A new user account has been created for contractor ${user.firstname}</div><div>&nbsp;</div><div><b>Username:</b> ${user.systemUserName}</div><div><br></i></div>"

 %>

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 15 2021 at 16:57 UTC

Sai,


What is the error that you get ?


Reviewing the error from the logs would be a good way to resolve these issues.



Regards,

Avinash Chhetri

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.

Community_User
Saviynt Employee
Saviynt Employee
Originally posted on November 22 2021 at 20:40 UTC

Sai,


I've attached an if else sample.



Regards,

Avinash Chhetri

This message was previously posted on Saviynt's legacy forum by a community user and has been moved over to this forum for continued exposure.