I am new to salesforce and my scenario is like this:
Based on the status value of Case object I need to make the link present in HTML email template dynamic. ie.:
If I select Closed as status value then the link in the email should be changed to "www.example.com".
If I select New as status value then link in the email should be changed to "www.example.org".
I tried using a if statement but it doesn't seem to work, as it is displaying the merge field as it is.

2 Answers 2


1) You can create two workflows on case that has condition based on the status value. For first workflow conditon is status == new For first workflow conditon is status == closed Associate different email template according to your requirement.

2) You can Create a formula filed in that you can change the value of the formula field based on the picklist value and then you can send the formula field value in the email template.


Three ways as far I understand:

  1. Create a URL field and populate values in the URL using a trigger and then use this field in the email template
  2. Create a formula field and use that field in the email template
  3. Create a visualforce email template like the one below:

    <messaging:emailTemplate subject="Helloooooo" recipientType="User" relatedToType="Case">
    <messaging:htmlEmailBody > 
    <apex:outputLink rendered="{! If(relatedTo.Status=='Closed' ,true,false) }">http://Google.com</apex:outputLink>
    <apex:outputLink rendered="{! If(relatedTo.Status=='New' ,true,false) }">  http://Yahoo.com</apex:outputLink>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .