We wanted to block this email template Access Request Validated - For Requester from sending emails to a service account. I have tried using the following code to block emails but it hasn’t worked:
#if($requesterName.contains(“sa-idn”))#stop#{else} Your Request Was Successfully Submitted. #end
Hi Zenia,
Are you adding this logic to the subject of the email template? Also, I’m looking at the docs for this email template and I don’t see $requesterName
listed as an object provided in the template. Are you sure that $requesterName is valid?
I tried this too: #if($user.name==“sa-idn IdMAdmin”)stop#{else} Your Request Was Successfully Submitted. #end - that doesn’t seem to work. Should it be the exact displayname?
Here’s what I tried.
If I use #if($user.name.contains(“Colin”))#stop#{else} Don’t Send #end in the subject, then it won’t send the email since $user.name is “Colin McKibben”. If i use #if($user.name.contains(“John”))#stop#{else} Do Send #end, then it will send the email since “John” is not in my user name.
Thank you, Colin but I am still getting the emails in our test environment. Attached screenshot.
Code: #if($user.name.contains(“sa-idn”))#stop#{else} Your request was successfully submitted. #end
Might just have an outlook rule.
This sounds like a similar issue in this post: Using an If statement in an email template - #34 by Rich_Miller
There could be a bug in email templates that prevent users from using variables inside if statements. I’m going to tag this topic to the engineering ticket so they are aware that it is affecting you as well.
Thanks for the heads up. I am working with one of the developers to dig into this further and will update you here once I have more info.
Rich
For email templates, when the initial message construction starts, the variable $user is not yet set, as the substitution phase occurs after evaluating the IF/ELSE logic blocks. So, at the point where the comparisons are being made, the $user variable doesn’t contain any data, and this is what causes the non-matching behavior you are seeing. This explains why the test email works, because the $user variable DOES exist when it is processed that way (the test uses the current user info).
To correct this, we will need to rework how the templates get processed, which will take some time (in other words, not a quick fix, as the work will need to be scoped, assigned, worked, and tested). I’ve created a development ticket for the appropriate team and will be monitoring their progress.
I don’t have any timeline yet when this will be fixed, but I’ll update this thread as I have additional information. Thanks for your patience, and please feel free to ask any questions you have.
Thank you very much, Rich!
Good morning @zxb323 ,
We have released a fix for this. Would you mind trying it out now and let me know if you encounter any further issues with this functionality?
Thanks! Rich