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
SFineSFine 

Displaying info based on criteria

Hello, I'm trying to only display certain information based on a certain criteria. For instance, in the following code, only the information within the outputfield should should if there is a value in the Hotel__c field. However, I can't seem to make that work. Can you offer any advice?

 

<outPutfield rendered="{!IF(ISBLANK(Travel_Service__c.Hotel__c), false, true)}">
     <tr>
         <td  colspan="5">HTL - {!Travel_Service__c.Hotel__c} - {!Travel_Service__c.Hotel_Confirmation_Number__c}</td>
         <td align="right" style="border-left:1px solid black;">
             <apex:outputText value="${0, number,###,##0.00}">
                 <apex:param value="{!Travel_Service__c.Hotel_Total_Cost__c}"/>
             </apex:outputtext>
         </td>
     </tr>
     <tr colspan="6" class="separator">
         <td  colspan="5"></td>
         <td style="border-left:1px solid black;"></td>
     </tr>

</outputField>

 

Edit: I have looked around the boards and found a few solutions, but none work. The closest one being as follows:

 

<outputfield rendered="{!NOT(ISBLANK(Travel_Service__c.Hotel__c))}">
     <tr>
         <td  colspan="5">HTL - {!Travel_Service__c.Hotel__c} - {!Travel_Service__c.Hotel_Confirmation_Number__c}</td>
         <td align="right" style="border-left:1px solid black;">
             <apex:outputText value="${0, number,###,##0.00}">
                 <apex:param value="{!Travel_Service__c.Hotel_Total_Cost__c}"/>
             </apex:outputtext>
         </td>
     </tr>
     <tr colspan="6" class="separator">
         <td  colspan="5"></td>
         <td style="border-left:1px solid black;"></td>
     </tr>
</outputfield>

 

Progress: I can make it so that fields are hidden when they don't have a value, but not when they do have a value, I get a 'value for outputfield is not a dynamic binding'. Any idea what that means? The new code is:

 

     <apex:outputfield rendered="{!NOT(ISBLANK(Travel_Service__c.Auto_Provider__c))}">
     <tr>
         <td  colspan="5">AUTO - {!Travel_Service__c.Auto_Provider__c} - {!Travel_Service__c.Auto_Conf__c}</td>
         <td align="right" style="border-left:1px solid black;">
             <apex:outputText value="${0, number,###,##0.00}">
                 <apex:param value="{!Travel_Service__c.Auto_Total_Cost__c}"/>
             </apex:outputtext>
         </td>
     </tr>
     <tr colspan="6" class="separator">
         <td  colspan="5"></td>
         <td style="border-left:1px solid black;"></td>
     </tr>
     </apex:outputField>

Best Answer chosen by Admin (Salesforce Developers) 
SFineSFine

thanks, but I found a solution:

 

<tr colspan="6" style="display:{!IF(ISBLANK(Travel_Service__c.Hotel__c),'none','')}" width="100%">    

All Answers

DharmeshDharmesh

I think you also need to check null value as described here

 

!IF(ISBLANK(Travel_Service__c.Hotel__c) || ISNULL(Travel_Service__c.Hotel__c), false, true)

SFineSFine

Thanks, but it doesn't seem to change anything from my initial problem

Imran MohammedImran Mohammed

Try using in the basic way,

<apex:outPutfield rendered="{!IF(Travel_Service__c.Hotel__c != null, true, false)}">

SFineSFine

thanks, but I found a solution:

 

<tr colspan="6" style="display:{!IF(ISBLANK(Travel_Service__c.Hotel__c),'none','')}" width="100%">    

This was selected as the best answer