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

Email filter by user employee Type.

ewalton
Regular Contributor
Regular Contributor

Hello, 

I am trying to send an email using a filter in the "To" field which will allow me to send an email based on employeeType. Below is the filter I am trying to use but I am uncertain if the syntax is correct. Does capitalization matter? Any help would be greatly appreciated. I am trying to send to the TestUsers email and for all other user types, send to the secondary email. 

${if(user?.employeeType.equalsIgnoreCase('TestUser')){user.email} else{user.secondaryEmail}}

Thank you in advance!

4 REPLIES 4

rushikeshvartak
All-Star
All-Star

Syntax is correct and capital letter matters

${if(user?.employeeType.equalsIgnoreCase('TestUser')){user.email} else{user.secondaryEmail}}

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


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

Thank you! What if I wanted to include a condition to NOT send an email based on employeeType. Is that possible? So if employeeTpye = TestUser2, do not send an email. Can this be included as well? 

Thanks again!

Will this work if I wish to NOT send an email to users where employeeType = TestUser2?

${if(user?.employeeType.equalsIgnoreCase('TestUser')){user.email} else if(user?.employeeType.equalsIgnoreCase('TestUser2')){''} else{user.secondaryEmail}}

Yes, your conditional expression should work for the scenario you described. Let's break it down:

  1. ${if(user?.employeeType.equalsIgnoreCase('TestUser')){user.email}: This part checks if the employeeType is equal to 'TestUser'. If it is, it returns user.email.

  2. else if(user?.employeeType.equalsIgnoreCase('TestUser2')){''}: This part checks if the employeeType is equal to 'TestUser2'. If it is, it returns an empty string ''.

  3. else{user.secondaryEmail}}: This part covers all other cases where employeeType is neither 'TestUser' nor 'TestUser2'. In such cases, it returns user.secondaryEmail.

So, according to your expression:

  • If employeeType is 'TestUser', the email will be sent to user.email.
  • If employeeType is 'TestUser2', no email will be sent (empty string).
  • For all other cases, the email will be sent to user.secondaryEmail.

This logic ensures that emails are not sent to users with employeeType equal to 'TestUser2', while handling other cases appropriately.


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