I'm trying to render some content in a Visualforce email if specific boolean fields are true. I have 6 boolean fields I'd like to verify.

Using apex:outputPanel I'm able to do the following:

<apex:outputPanel rendered ="{!relatedto.Agency__c}">

For the life of me, I can't figure out the syntax to check each additional boolean field. I've tried 14(!) different combos.

<apex:outputPanel rendered="{!relatedto.Agency __c} || {!relatedto.Food_bev_manufacturers__c}">  
<apex:outputPanel rendered="({!relatedto.Agency __c} || {!relatedto.Food_bev_manufacturers__c})"> 
 <apex:outputPanel rendered="{!relatedto.Agency __c} || {!relatedto.Food_bev_manufacturers__c}"> 
 <apex:outputPanel rendered="(!relatedto.Agency __c || !relatedto.Food_bev_manufacturers__c)">  
 <apex:outputPanel rendered="{relatedto.Agency __c || relatedto.Food_bev_manufacturers__c}"> 
    <apex:outputPanel rendered="OR(relatedto.Agency __c, relatedto.Food_bev_manufacturers__c)"> 
    <apex:outputPanel rendered="{OR(relatedto.Agency __c, relatedto.Food_bev_manufacturers__c)}"> 
    <apex:outputPanel rendered="{OR(!relatedto.Agency __c, !relatedto.Food_bev_manufacturers__c)}">  
    <apex:outputPanel rendered="{IF(OR(relatedto.Agency __c, relatedto.Food_bev_manufacturers__c))}">   
    <apex:outputPanel rendered="OR(!relatedto.Agency __c, !relatedto.Food_bev_manufacturers__c)}"> 
    <apex:outputPanel rendered="!OR({relatedto.Agency__c},{relatedto.Food_bev_manufacturers__c})"> 
    <apex:outputPanel rendered="OR({relatedto.Agency__c},{relatedto.Food_bev_manufacturers__c})"> 
    <apex:outputPanel rendered="!OR({!relatedto.Agency__c},{!relatedto.Food_bev_manufacturers__c})">

Any insight would be appreciated!


The basic frame of a Visualforce expression is {! }. You use it only at the outermost level of an attribute.

The ! character is also used as a Boolean negation within an expression.

From your examples, if looks like the form you want is this:

<apex:outputPanel rendered="{! OR(relatedto.Agency__c, relatedto.Food_bev_manufacturers__c) }"> 

This is equivalent to an expression with the || Boolean OR operator:

<apex:outputPanel rendered="{! relatedto.Agency__c || relatedto.Food_bev_manufacturers__c }"> 

Should you need to negate one of your Booleans, you'd prefix it with !:

<apex:outputPanel rendered="{! OR(relatedto.Agency__c, !relatedto.Food_bev_manufacturers__c) }"> 
  • Thank you so much. The whole {! } thing really confuses me. I will have to read the docs and do Trailhead. Appreciate your swift assistance. – Cynthia Oct 20 '18 at 22:19
  • Just remember that any attribute where you want to use an expression is attribute="{! STUFF_HERE }". You only worry about the STUFF_HERE. – David Reed Oct 20 '18 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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