Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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
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)}
share|improve this answer
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


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.