and more in a single search tool across platforms. Read the announcement here. |
03/26/2024 01:18 PM
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!
Solved! Go to Solution.
03/26/2024 07:44 PM
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" + ">"}}
03/27/2024 07:56 AM
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!
03/27/2024 08:00 AM
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}}
03/27/2024 07:49 PM
Yes, your conditional expression should work for the scenario you described. Let's break it down:
${if(user?.employeeType.equalsIgnoreCase('TestUser')){user.email}: This part checks if the employeeType is equal to 'TestUser'. If it is, it returns user.email.
else if(user?.employeeType.equalsIgnoreCase('TestUser2')){''}: This part checks if the employeeType is equal to 'TestUser2'. If it is, it returns an empty string ''.
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:
This logic ensures that emails are not sent to users with employeeType equal to 'TestUser2', while handling other cases appropriately.