Click HERE to see how Saviynt Intelligence is transforming the industry. |
10/05/2022 02:44 AM
Hello,
I'm trying to define a condition with the following values below on the body of email and it doesn't trigger an email notification.
<% if (${user.customproperty11} == null)
print "QR Code not found, please contact Support"
else
<img src="https://xxxxxxx/chart?cht=qr&chs=350x350&chl=${user.customproperty11}">
%>
However, when I changed the operator <% %> into {% %} it then triggers an email but it doesn't read the html code as conditional statement instead it displays below output.
Solved! Go to Solution.
10/05/2022 05:30 AM
<% if (user.customproperty11 == null) print "QR Code not found, please contact Support" else "<img src=\"https://xxxxxxx/chart?cht=qr&chs=350x350&chl=${user.customproperty11}\">"%>
try simple logic without adding img tag in else, You need to escape " in QR URL
<% if (user.customproperty11 == null) print "QR Code not found, please contact Support" else "QR"%>
10/05/2022 06:03 AM
I've tried what you've suggested but it doesn't send an email. Also, I don't see anything from the logs that's blocking it.
10/05/2022 06:19 AM
print ${user.custompropery11}
it might be blank & not null
10/05/2022 05:17 PM
Still not working.
10/05/2022 07:47 PM - edited 10/05/2022 07:48 PM
Turn off html content flag n try,
Which email trigger are you attaching email template ?
10/05/2022 08:10 PM
No luck, it doesn't send an email. I'm trying to attach the email to a user update rule and even try creating a separate email for analytic. If I removed the if else condition, it then sends an email. So I'm guessing that problem is the conditional statement.
10/05/2022 08:28 PM
Validate variables exposed in email template using below script add in email body.
Its possible user object is not exposed.
${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}
10/05/2022 08:59 PM
I tried this email for testing purposes. but didn't trigger an email.
10/06/2022 04:50 AM
Remove all logics related to analyticsdata from subject & email body & try
10/06/2022 04:50 PM
I have removed the conditional statement and just left the below variables. It then sends an email. But when I added back the if else statement it doesn't send the email again. Is the conditional statement really working on the email template?
${this.binding.variables.each {k,v -> println "$k = $v" + "<" + "br" + ">"}}
10/06/2022 05:27 PM
Please share output of above variable
10/06/2022 05:43 PM
Here you go.
10/06/2022 05:50 PM
There is no user object in analytics hence its failing hence attach same variable template on user update rule & share output )
10/06/2022 06:08 PM
This is the email triggered from user update rule
10/06/2022 06:13 PM
There is no user object in Email template hence your logic will not work
<% if (user == null) print "User Object is nulll" else "User object found"%>
10/07/2022 06:45 AM
So you want to trigger an email on user update and based on the user's custom property value, you are looking to conditionally format the content of the email being sent ?
10/09/2022 03:09 PM
Correct but when I added the html image syntax inside the if else, it's doesn't trigger an email.
10/09/2022 03:12 PM
Without html tag also its not triggering correct because user object is not exposed
10/09/2022 03:26 PM
When I removed the dollar sign on the user.customproperty11 and <img> tag it sends an email. What do you mean by user object not exposed? Is there anything I needed to do on my end for the html image syntax to work?
10/09/2022 05:36 PM
Can you share current working syntax & output screenshot
10/09/2022 06:17 PM
This one worked
<% if (user.customproperty11 == null) print "QR Code not found, please contact support" else print "test email notif" %>
While this one doesn't have an output as email didn't trigger, because of the img tag
<% if (user.customproperty11 == null) print "QR Code not found, please contact support" else print <img src="https://xxxxxxxxxxx=user.customproperty11"> %>
10/09/2022 07:31 PM
Its working for me
Steps
1. create template with html =false
2. save
3. update email template to html= true
4. email template print message in single quote
O/p
10/09/2022 08:18 PM
Thanks a lot, Rushikesh. It's now working for the User Update Rule. I'll try to play around with the Analytics configuration to see if it will trigger an email too using the conditional statement and Analytics variable.
10/11/2022 02:03 AM
I just noticed that when I used the syntax below it sends an email but it doesn't get the expected result.
<% if (user.customproperty11 == null) print "QR Code not found, please contact support" else print '<img src="https://xxxxxxxxxxx=user.customproperty11">' %>
I even tried the different variables for the img src like ${user?.customproperty11} and ${user.customproperty11} and yet it's not displaying the QR code.
I also tried the HTML links -syntax but it's not working as expected.
<% if (user.customproperty11 == null) print "QR Code not found, please contact support" else print '<a href="${user.customproperty64}">Register for Passwordless Authentication</a>' %>
10/11/2022 03:53 AM
On first email if you download picture does it working
10/11/2022 03:58 AM
Nope, it doesn't work.