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
Gareth HennedyGareth Hennedy 

Issue with Opportunity.Account field when used in email template with IF statement

Hi,

I am trying to use the following syntax in an email template.....

{!if(Account.Parent="",Opportunity.Account,Account.Parent)} 

.....What this says in english is "If Parent Account Name is empty, replace Parent Account Name with Opportunity Account Name"......

However, when this statement is activated (i.e. the Parent Account is empty) it is replaced with the Opportunity AccountID ??

When I remove the IF statement and simply use {!Opportunity.Account} the Account Name is presented...

Any ideas why this is happening?

Thanks in advance
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi ,

Try Using this :
{!if(Account.Parent="",Opportunity.Account.Name,Account.Parent)}

Its because Opportunit.account point to AccountID. (Lookup field Value) which is Id.

Let me know, in case of any doubts.

Hope this helps.
--
Thanks,
Swayam
 
Gareth HennedyGareth Hennedy
Thanks....

I tried this but no luck.  It still produces the AccountID.

Any other thoughts?

Kind Regards
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

On which object the email template related to :-

If its on Account you can use :-
{!if(Account.Parent="", Account.Name,Account.Parent)}
else if its on Opportuntiy you can use :-
{!if(Opportunity.Account.Parent="", Opportunity.Account.Name,Opportunity.Account.Parent)}
Hope this helps,

--
Thanks,
Swayam
 
Swayam@SalesforceGuySwayam@SalesforceGuy
Also one think, Try to print :- {!Account.Parent} it might me not empty, and printing parent accountID
Gareth HennedyGareth Hennedy
The Email Template is related to the opportunity.

i.e. within the Opportunity I use the 'Send Email' button within the 'Activity History' section.

I tried {!if(Opportunity.Account.Parent="", Opportunity.Account.Name,Opportunity.Account.Parent)} above as you suggested however this did not resolve the issue.

I did notice that when I updated the email template with the your suggestion {!if(Opportunity.Account.Parent="", Opportunity.Account.Name,Opportunity.Account.Parent)} when it is saved the 'HTML Preview' does not show the 3rd part of the fields e.g. Opportunity.Account.Parent is still Opportunity.Account.......

could this have anything to do with it?  The code behind remains as  {!if(Opportunity.Account.Parent="", Opportunity.Account.Name,Opportunity.Account.Parent)} if I re-edit.

Any other suggestions?
Gareth HennedyGareth Hennedy
Also tested printing
{!Account.Parent} and it is empty
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

Can you share you're email template 

--
Thanks,
Swayam
Gareth HennedyGareth Hennedy
Here is the paragraph in question in case it helps.....

<p>This email is to notifiy you that the attached purchase order has been raised on behalf of <strong>{!Opportunity.Primary_Contact__c}</strong> at <strong> 
    {!if(Opportunity.Account.Parent="", Opportunity.Account.Name,Opportunity.Account.Parent)}
   </strong>.</p>
Gareth HennedyGareth Hennedy
<html>

<style type="text/css">
a:link {
    color: #ef7e16;
}


</style>
<body style="font-family:Arial, Helvetica, sans-serif; font-size: 12px/16px; padding: 0px; margin: 10px; background-color: #ffffff;">

 <table cellpadding="0" cellspacing="0" border="0" width="850">
 
 <tr>

 <td width="900">


<!-- Start Banner -->
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
        
<!-- Start Text Cell -->
          <td width="850">

          <p width="850"> <img src=`"https://carestream--c.na32.content.force.com/servlet/servlet.ImageServer?id=01550000001d4DP&oid=00D500000007lTc&lastMod=1421598553000" width="164" height="70" alt="Carestream" ></p>
          <p style="margin: 10px 0; font-family:Arial, Helvetica, sans-serif; font-size: 18px;  color: #ef7e16;" width="850"><strong>{!TODAY()} - Purchase Order Recieved Notification</strong> <br>
            Customer: {!Opportunity.Primary_Contact__c}<br>
            Parent Account: {!Account.Parent}<br>
            Ref: {!Opportunity.Name}</br>
          </p></td>

<!-- End Text Cell -->

<td style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #848484; " align="right" width="350">

<p valign="bottom">
         <b> Joe Bloggs <br> Account Manager - Scotland</br></b>
         
         </p>
         
         </td>

<!-- Start Picture Cell -->        
            
            <td align="right" valign="bottom" width="85">&nbsp;</td>
            
<!-- End Picture Cell -->
         </tr>
      </table>
<!-- End Banner -->



<!-- Start Intro Message -->

<table cellpadding="0" cellspacing="0" border="0" top-margin >
        <tr>
        <!-- Start Text Cell -->
        <td  valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; padding-top: 20px; ">
         <p> To: <strong>The Project Management Team </strong></p>
         <p>This email is to notifiy you that the attached purchase order has been raised on behalf of <strong>{!Opportunity.Primary_Contact__c}</strong> at <strong> 
    {!if(Opportunity.Account.Parent="", Opportunity.Account.Name,Opportunity.Account.Parent)}
   </strong>.</p>
         <p>You can access the Salesforce Opportunity directly from this email - <a href = "{!Opportunity.Link}"><strong> Click Here </strong></a>
         <p valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; "> Let me know if you have any questions regarding this. </p>
          <p valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;">&nbsp;</p></td>  

        <!-- End Text Cell -->    


        </tr>
      </table>    
     
<!-- End Intro Message -->


<!-- Start Stationary-->

<table cellpadding="0" cellspacing="0" border="0" width="850" >
    
      <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #848484; padding-top: 20px; ">
        
        <td>
         <b>Kind Regards</b>
         
         </td>
        
        
        </tr>

     <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #848484; ">
        
        <td>
         <b> Job Bloggs | Key Account Manager - Scotland</b>
         
         </td>
        
        
        </tr>
        
         <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #ef7e16;">
    
    <td>
        Some Company
        
        </td>
        
        </tr>
        
         <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #ef7e16;">
    
    <td>
        test@somecompany.com
        
        </td>
        
        </tr>
        
         <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #848484;">
    
    <td>
        Office: 0000000000
        
        </td>
        
        </tr>
        
         <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #848484;">
    
    <td>
        Mobile: 000000000000
        
        </td>
        
        </tr>
        
         <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #848484;">
    
    <td>
        CNET: 00000000000
        
        </td>
        
        </tr>
        
    
        
         <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #ef7e16;">
    
    <td>
        www.somecompany.com
        
        </td>
        
        </tr>
        
         <tr valign="top" width="850" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #848484;">
    
    <td>
        Some Company. 1 kent road
        
        </td>
        
        </tr>
        
        <!-- End Stationary-->
      
      
    </table>  
      

</table>          
          

</body>

</html>
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

It has been issue with HTML template, you can either convert it to visual force or do it directly can't help :P
Issu is = you can have string in condition if, but not field value

Please refer this idea -- https://success.salesforce.com/ideaView?id=08730000000BrdX

--
Thanks,
Swayam