02/14/2023 08:15 AM
Hello,
I need some help with an email template. I have an email configured to go out on new account creation, however the logic for my To field seems to be evaluating as null.
Below is the to field logic:
<% if (user.username.startsWith('xt')) print "${manager?.email}" %>
I've put the manager as myself, and my account has the email field filled out. Is the startsWith method not valid for email templates? The user's username starts with xt.
No error but below is the To field population in the logs
Solved! Go to Solution.
02/14/2023 08:31 AM
Do you see any error in logs?
Also does the user name of the user is starting with 'xt' with same case?
02/14/2023 08:36 AM
As mentioned in the original post there is no error in the log and user's name starts with xt in same case.
02/14/2023 08:48 AM - edited 02/14/2023 08:50 AM
And I assume you configured this email template as Task completion on New Account?
try below
<% if (user.username.substring(0,1).equalsIgnoreCase('xt')) print "${manager?.email}" %>
If still doesn't work please share the user screenshot showing username and manager field, Manager screenshot with email and also email template
02/14/2023 09:50 AM
This one didn't appear to work either, however it isn't showing null.
debug log:
Here is the user screenshot with username and manager shown.
Manager screenshot with email filled out
Email template screenshot:
02/14/2023 01:01 PM
Can you share output of below (add into email body)
${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}
02/15/2023 06:04 AM
Got the below in the debug log
02/15/2023 06:27 AM
can you enable advanced css on email template
02/15/2023 12:23 PM
The solution that worked was
<% if(user.username.substring(0,2).equalsIgnoreCase(‘xt’)) print “${manager?.email}” %>
@sk your previous solution was good just needed to be substring(0,2) and not (0,1)
Thanks.
02/15/2023 12:38 PM
Just to understand Enable Advanced CSS worked along with corrected substring statement?