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
Chiel de Graaf.Chiel de Graaf. 

Showing records in VF based on a field value

Hi all,

I have made a start with a visual force page to show specific records based on a field value. I've got the next code that displays all the records (but hides them when the value of field is other then "Opgelost"). What i want to achieve is that only the records with the value "Opgelost" in the field are shown.

Which bit of code should i add ?

<apex:page standardController="Storing__c" recordSetVar="Storingen">
    <apex:repeat value="{!storingen}" var="c">
            <apex:pageblock >
                    <apex:outputText value="{!c.Id}" rendered="{!c.Status__c =='Opgelost'}" />
                    <br/>
                    <apex:outputText value="{!c.Soort_storing__c}" rendered="{!c.Status__c =='Opgelost'}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Status__c}" rendered="{!c.Status__c =='Opgelost'}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Systeem__c}" rendered="{!c.Status__c =='Opgelost'}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Voor_welke_klanten_geldt_dit__c}" rendered="{!c.Status__c =='Opgelost'}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Wat_is_het_probleem__c}" rendered="{!c.Status__c =='Opgelost'}" style="font-weight:bold" />
                    <br/>
        </apex:pageblock>             
    </apex:repeat>
</apex:page>
Best Answer chosen by Chiel de Graaf.
Abhishek BansalAbhishek Bansal
Hi,

Please modify your page code as below :
<apex:page standardController="Storing__c" recordSetVar="Storingen">
    <apex:repeat value="{!storingen}" var="c">
            <apex:pageblock rendered="{!If(c.Status__c =='Opgelost',true,false)}" >
                    <apex:outputText value="{!c.Id}" />
                    <br/>
                    <apex:outputText value="{!c.Soort_storing__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Status__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Systeem__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Voor_welke_klanten_geldt_dit__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Wat_is_het_probleem__c}" style="font-weight:bold" />
                    <br/>
        </apex:pageblock>             
    </apex:repeat>
</apex:page>
 
Let me know if you have any issue in this.

Thanks,
Abhishek

All Answers

Abhishek BansalAbhishek Bansal
Hi,

Please modify your page code as below :
<apex:page standardController="Storing__c" recordSetVar="Storingen">
    <apex:repeat value="{!storingen}" var="c">
            <apex:pageblock rendered="{!If(c.Status__c =='Opgelost',true,false)}" >
                    <apex:outputText value="{!c.Id}" />
                    <br/>
                    <apex:outputText value="{!c.Soort_storing__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Status__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Systeem__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Voor_welke_klanten_geldt_dit__c}" style="font-weight:bold" />
                    <br/>
                    <apex:outputText value="{!c.Wat_is_het_probleem__c}" style="font-weight:bold" />
                    <br/>
        </apex:pageblock>             
    </apex:repeat>
</apex:page>
 
Let me know if you have any issue in this.

Thanks,
Abhishek
This was selected as the best answer
Chiel de Graaf.Chiel de Graaf.
Indeed, that's the code i've been looking for.

Thanx a lot Abhishek
Abhishek BansalAbhishek Bansal
Please close this question if you have got your solution that will help others to find a solution and also avoids the confusion.

Regards,
Abhishek