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
lil_rangerlil_ranger 

Make field display if not null

<b>12. Purchase Order #: </b><apex:outputfield value="{!Contract.Purchase_Order_Number__c}"/>

 How would I make this line show up only if something is typed in the purchase order field?

 

And then if null it would skip that line completely and go to the next part of the page.

 

Thanks!

SidharthSidharth

May be 'rendered' attribute  will help. Something like:

 

<apex:outputfield rendered="{!IF(Contract.Purchase_Order_Number__c != null)}" value="{!Contract.Purchase_Order_Number__c}" />

ptepperptepper

This is the incorrect syntax for if statements in formulas: !IF(Contract.Purchase_Order_Number__c != null)

 

It's !IF(condition,consequent,alternative)}  (functions are not actually case sensitive)

 

However, fo rendered you probably wouldn't want an if statement. You just need the condition which evaluates to a boolean - i.e. "Contract.Purchase_Order_Number__c != null"

 

Neena BainsNeena Bains

To add onto what ptepper said above, you could rewrite as:

<apex:outputField rendered="{!Contract.Purchase_Order_Number__c != NULL}" value="{!Contract.Purchase_Order_Number__c}" />