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
poonam wadhwani 9poonam wadhwani 9 

How to show opportunities with stage="qualify" in tabular format?

HI,

I want to display all apportunitites of an acount which are in stage "Qualify" .

I have created a table with below code.This code displayes all opportunitties.I want to show only "Qualify" opportunities.

<apex:page standardController="Account">
   
    <apex:pageBlock title="Edit Account for {!$User.FirstName}">
        Youa are viewing the {!account.name} Account
        </apex:pageBlock>
         <apex:pageBlock title="Opportunities">
        <apex:pageBlockTable value="{!ACCOUNT.Opportunities}" var="opportunity">
            <apex:column value="{!opportunity.name}"/>
            <apex:column value="{!opportunity.type}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
           
     
</apex:page>

 
Ankit SehgalAnkit Sehgal
Use a custom controller AND retrieve records as per your requirements.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Just add rendered to the apex:column
rendered="{!If(opportunity.StageName=='Qualify',true,false)}"
poonam wadhwani 9poonam wadhwani 9
Hi,

Thanks for the responses!!

I tried custom controller and could get the expected result.But when I have 0 opty with stage = qualify, I am getting below meesage.


"List has no rows for assignment to SObject 
An unexpected error has occurred. Your development organization has been notified."

Can you please let me know how that arrives?I am expecting a blank table.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
<apex:page standardController="Account">
   
    <apex:pageBlock title="Edit Account for {!$User.FirstName}">
        Youa are viewing the {!account.name} Account
        </apex:pageBlock>
         <apex:pageBlock title="Opportunities">
        <apex:pageBlockTable value="{!ACCOUNT.Opportunities}" var="opportunity">
            <apex:column value="{!opportunity.name}" rendered="{!If(opportunity.StageName=='Qualify',true,false)}"/>
            <apex:column value="{!opportunity.type}" rendered="{!If(opportunity.StageName=='Qualify',true,false)}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
           
     
</apex:page>

Try this