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
Vanessa BarrosVanessa Barros 

an opinion

hi!

i had made a visualforce page of a custom object calls zones__c and one of the related list is opportunities.

when i list oportunities, shows all of the opportunities but i want to filter by stagename = closed Won.

 

what is the best way? component? extended controller?

can anyone gives me an example please?

tks!

hisrinuhisrinu

You can just use an extension where you can query the opportunity and apply the where clause.

 

Sample Query

Select id from opportunity where opportunity__c = :yourId and stagename = 'Closed Own'

Pradeep_NavatarPradeep_Navatar

You can use SOQL Query in a controller extension to get list of opportunities by using filter criteria. Go through the sample code given below :

 

        controller code:

        public class cls_oppcontroller

        {

        public cls_oppcontroller(ApexPages.StandardController acon){}

        public List<opportunity> getopportunites()

        {

        List<opportunity> opp = [select StageName,name from opportunity o where o.name = 'closedwon'];

        return opp;

        }

        }

 

Hope this helps.

Vanessa BarrosVanessa Barros

hum..ok. but i forgot something.. i have professional :(


Pradeep_Navatar wrote:

You can use SOQL Query in a controller extension to get list of opportunities by using filter criteria. Go through the sample code given below :

 

        controller code:

        public class cls_oppcontroller

        {

        public cls_oppcontroller(ApexPages.StandardController acon){}

        public List<opportunity> getopportunites()

        {

        List<opportunity> opp = [select StageName,name from opportunity o where o.name = 'closedwon'];

        return opp;

        }

        }

 

Hope this helps.