You need to sign in to do that
Don't have an account?
tawfik-hai
Visualforce template to skip blank fields
hi everyone,
Anyone knows how to make Visualforce templates skip blank fields in the output?
For example, a visualforce templates which populates fields from the
opportunity product page with the following fields:
<td> {!opp.Survey_Question_2__c}</td><br/>
<td> {!opp.Survey_Question_3__c}</td><br/>
<td> {!opp.Survey_Question_4__c}</td><br/>
<td> {!opp.Survey_Question_5__c}</td><br/>
If 3 and 4 are blank, how to make the template skip them to avoid blank lines in the output?
thanks in advance.
<apex:outputText rendered="{!IF(opp.Survey_Question_2__c='','false','true')}"> <td>{!opp.Survey_Question_2__c}</td> </apex:outputText>
Enclose the output you would like (including tags) inside a tag (I used an "outputText" tag in this example), and set the tag's "rendered" attribute to true or false based on the presence of a value (in this case, if the field is empty an empty string, do not display the entire contents of the tag). Note that some fields use ISNULL(fieldName) while some use fieldName='' to detect blank values (text fields are never null, only empty, while numbers, dates, etc are null, not empty).