function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chris Sanchez 5Chris Sanchez 5 

email template conditional hyperlink

Hello - Is it possible to use a conditional hyperlink in an HTML email template?  I have a URL link similar to this that works without using conditions that I can pass in the Account Name.  
https://www.siteName.com//form5/fill?id712={!Account.Name}_FRVP&

How can I add a condition to work something like this?
https://www.siteName.com//form5/fill?id712={!IF(Verification_Report__c.ReportSelection__c = "",Verification_Report__c.Status__c,Verification_Report__c.InactiveStatus__c)}

I have a similar URL working in a button but that logic doesnt want to transfer over to an email template.  Any help is appreciated.  Thank You
 
Neha AggrawalNeha Aggrawal
Hi Chris,

Currently email tempalte does not allow merge field from cross objects. See this link:
https://success.salesforce.com/ideaview?id=08730000000Brk7AAC
Only option is to pull the fields (that is the Report selection, Status and Inactive Status fields) from Verification Report object to the parent object using formula fields.
Once you create formula fields, your if condition should work.

On the other hand, rather then creating 3 formula fields, and then checking the if condition in email template, it would be better to create a formula field which checks your if condition. Since formula fields have no restrictions over the use of cross object fields.
Let me know how that works for you.

Thanks.

 
Chris Sanchez 5Chris Sanchez 5
Hello – Actually I am not using cross objects. Well, I was trying to mask my original URL so I gave you a bad example, sorry about that. I used that example as that’s the URL that works for me in a button. What I am really trying to do is, create an email template that will be sent from either the Account or Opportunity object. If sent from the account I want to pass in a field from the account to the URL and if sent from the opportunity I want to pass in a field from the opportunity. My URL will actually look something more like this. I am crossing objects from the Opportunity to Account but in my tests those two objects do communicate nicely. https://www.siteName.com//form5/fill?id712={!IF(!Opportunity.ReportSelection__c = "",!Account.Status__c,!Opportunity.InactiveStatus__c)} Any suggestions how I can accomplish this? Thanks, Chris
Neha AggrawalNeha Aggrawal
Hi Chris,

You can try something like this:  https://www.siteName.com//form5/fill?id712={! IF(ispickval(Opportunity.ReportSelection__c ,''),Account.Status__c,Opportunity.InactiveStatus__c)}
Though if you are working with picklist fields, they dont work very well with IF condition. Better to create formula field.
Thanks.



 
Jade Fischer 24Jade Fischer 24
We had this same issue and could only find 1 source with the correct answer.  You need to concatenate the string for it to work.  The IF function will not recongnize the merge fields.  This needs a Salesforce Idea created for this because it isn't very intuitive.  Here is an example:

{!IF(Account.Name == 'John Doe','<a href=" ' & Account.Link & ' ">Account Record</a>','')}

The merge field is the Account.Link and you don't use the {!SomeObject.field} format that you usual copy from the field merge field search box above you just need to use dot notation.