Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am display table rows in my email template...

<tr>
    <td>{!relatedTo.opportunity__r.name}</td>
    <td>{!relatedTo.opportunity__r.stageName}</td>
</tr>

However it is possible for opportunity__r to be null. I only want to add a row if the my custom object is pointing to a valid opportunity.

Any tips?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Wrap the block in an outputPanel and use rendered attribute and have a logic to render only if the value is not equal.Please note this you can have only if your email Template is a Visualforce template .

<apex:outputPanel rendered={!IF(relatedTo.opportunity__r.stageName!=null)}
<td>{!relatedTo.opportunity__r.stageName}</td>
</apex:OutputPanel>
share|improve this answer
1  
this almost I workds. I had to do: <apex:outputPanel rendered="{!IF(relatedTo.opportunity__r !=null, true, false)}"> I was interested in the Opportunity reference was null or set. –  dublintech Dec 31 '12 at 15:13
    
I think rather than writing rendered={!IF(relatedTo.opportunity__r.stageName!=null)} you should use rendered={!relatedTo.opportunity__r.stageName !=null}. there is not need to use if statement –  Pramod Kumar Dec 31 '12 at 18:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.