+ Start a Discussion
Adam RycroftAdam Rycroft 

Display text along with field if not null in Visualforce

Hi,

I'm struggling to get this to work correctly. I have a VF page rendered as a pdf. If there is a phone number extension, it should include that after the phone number. That part of the formula works fine - what I want it to do is if there is an extension to display 'ext.' before it. How would I add that in?
<b>Phone Number:</b>&nbsp;<apex:outputfield value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_s_Phone_Number__c}"/>&nbsp;Ext.<apex:outputField rendered="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c != NULL}" value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c}"/><br></br>

 
Best Answer chosen by Adam Rycroft
Raj VakatiRaj Vakati
Try this 
 
<b>Phone Number:</b>&nbsp;<apex:outputfield value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_s_Phone_Number__c}"/>
<apex:outputText rendered="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c != NULL}" >&nbsp;Ext.</apex:outputText ><apex:outputField rendered="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c != NULL}" value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c}"/><br></br>

 

All Answers

Raj VakatiRaj Vakati
Try this 
 
<b>Phone Number:</b>&nbsp;<apex:outputfield value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_s_Phone_Number__c}"/>
<apex:outputText rendered="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c != NULL}" >&nbsp;Ext.</apex:outputText ><apex:outputField rendered="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c != NULL}" value="{!Crisis_Bed_And_Motel_Vouchers__c.Provider_Phone_Extension__c}"/><br></br>

 
This was selected as the best answer
Adam RycroftAdam Rycroft
Thank you! I knew there was something I was missing.