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
Alimali Stephen 15Alimali Stephen 15 

If condition on visualforce page

Hello Team! 

I want to add IF condition on related custom object records that are added on a table in Visualforce email template.
e.g IF a record has a certain text then a certain column should show.
I have two fields that I would love to apply the IF condition. 
See code block I tried shared below:    
<apex:repeat var="Column Name" value="{!relatedTo.ObjectField__c}"> 

<apex:outputPanel rendered="{!IF(oli.ObjectField !== 'KG' || oli.ObjectField__c !== 'KGS' ,true,false)}"
          <tr>        
              <td  style="text-align:left;float:left;" width="195">
<apex:outputText value="{!ColumnName.ObjectField__c}" escape="false" />
              </td>
             <td width="195" style="text-align:left;float:left;">{!ColumnName.ObjectField__c}</td>
         </tr>
</apex:outputPanel>
</apex:repeat>
The condition is not working as expected. I would appreciate any assistance on this.
 
CharuDuttCharuDutt
Hii Stephen
Try Below Condition
{!If((oli.ObjectField != 'KG'),true,If((oli.ObjectField__c != 'KGS'),true,false))}
***********************************************************
{!IF(oli.ObjectField != 'KG' || oli.ObjectField != 'KGS' ,true,false)}
Please Mark It As Best Answer If It Helps
Thank You!
mukesh guptamukesh gupta
Hi Stephen,

Please use below code:-
 
<apex:repeat var="Column Name" value="{!relatedTo.ObjectField__c}"> 

<apex:outputPanel rendered="{!IF(oli.ObjectField !='KG'|| oli.ObjectField__c != 'KGS' ,true,false)}"
          <tr>        
              <td  style="text-align:left;float:left;" width="195">
<apex:outputText value="{!ColumnName.ObjectField__c}" escape="false" />
              </td>
             <td width="195" style="text-align:left;float:left;">{!ColumnName.ObjectField__c}</td>
         </tr>
</apex:outputPanel>
</apex:repeat>

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukes