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 Template To field method error

aundreb
Regular Contributor II
Regular Contributor II

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 

aundreb_0-1676391227919.png

 

9 REPLIES 9

sk
All-Star
All-Star

Do you see any error in logs?

Also does the user name of the user is starting with 'xt' with same case?


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

aundreb
Regular Contributor II
Regular Contributor II

As mentioned in the original post there is no error in the log and user's name starts with xt in same case.

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


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

aundreb
Regular Contributor II
Regular Contributor II

This one didn't appear to work either, however it isn't showing null.

debug log:

aundreb_0-1676396424488.png

Here is the user screenshot with username and manager shown.

aundreb_1-1676396735580.png

 

Manager screenshot with email filled out

aundreb_2-1676396880320.png

 

Email template screenshot:

aundreb_3-1676396997951.png

 

 

Can you share output of below (add into email body)

 

${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.

aundreb
Regular Contributor II
Regular Contributor II

Got the below in the debug log

aundreb_1-1676469871514.png

 

aundreb_0-1676469830144.png

 

can you enable advanced css on email template


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.

aundreb
Regular Contributor II
Regular Contributor II

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.

Just to understand Enable Advanced CSS worked along with corrected substring statement?


Regards,
Saathvik
If this reply answered your question, please Accept As Solution and give Kudos to help others facing similar issue.