• anuj kumar 98
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I need to retrieve  the records ( All opportunities with Closed won )  on selection of a checkbox (inputcheckbox)  on click of SEARCH command button on the page.
 
after searching around, all I have seen are references to using a wrapper class, which seems a little bit overboard for what I am looking to do. I am beginner in developer role. I am using the below code..

public class inputcheckbox{

    public boolean mycheckval { get; set; }
    public inputcheckbox() {
    mycheckval = false;
    }
    List<Opportunity> Opr;
    public List<Opportunity> getopr(){
        return opr;
    }
        public void closedWon(){
        if(mycheckval) {
        
        opr= [select name, stagename, closedate, expectedrevenue, probability from Opportunity where stagename= 'closed won'];
        
        //return null;
        }
    }   
        
}
VF:---

apex:page controller="inputcheckbox" sidebar="false" showHeader="false">
<apex:form >
            <apex:pageblock title="Search opportunity by stage"> 
        
            <apex:inputcheckbox value="{!mycheckval}" />
     
                  
            <apex:commandButton value="search" action="{!closedwon}"/>
            
            <apex:pageBlockTable value="{!opr}" var="a">
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.stagename}"/>
                <apex:column value="{!a.closedate}"/>
                <apex:column value="{!a.expectedrevenue}"/>
                <apex:column value="{!a.probability}"/>
        </apex:pageBlockTable>
        
        
  
        </apex:pageblock>
</apex:form>
</apex:page>


i am able to retriev whether the check box selected or not but not able to get it's value dynamically. i have hadcoded the stagename in SOQL and hence it's working based on selection of check box.. i need to have stagename dynamically based of selection of check box
I need to retrieve  the records ( All opportunities with Closed won )  on selection of a checkbox (inputcheckbox)  on click of SEARCH command button on the page.
 
after searching around, all I have seen are references to using a wrapper class, which seems a little bit overboard for what I am looking to do. I am beginner in developer role. I am using the below code..

public class inputcheckbox{

    public boolean mycheckval { get; set; }
    public inputcheckbox() {
    mycheckval = false;
    }
    List<Opportunity> Opr;
    public List<Opportunity> getopr(){
        return opr;
    }
        public void closedWon(){
        if(mycheckval) {
        
        opr= [select name, stagename, closedate, expectedrevenue, probability from Opportunity where stagename= 'closed won'];
        
        //return null;
        }
    }   
        
}
VF:---

apex:page controller="inputcheckbox" sidebar="false" showHeader="false">
<apex:form >
            <apex:pageblock title="Search opportunity by stage"> 
        
            <apex:inputcheckbox value="{!mycheckval}" />
     
                  
            <apex:commandButton value="search" action="{!closedwon}"/>
            
            <apex:pageBlockTable value="{!opr}" var="a">
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.stagename}"/>
                <apex:column value="{!a.closedate}"/>
                <apex:column value="{!a.expectedrevenue}"/>
                <apex:column value="{!a.probability}"/>
        </apex:pageBlockTable>
        
        
  
        </apex:pageblock>
</apex:form>
</apex:page>


i am able to retriev whether the check box selected or not but not able to get it's value dynamically. i have hadcoded the stagename in SOQL and hence it's working based on selection of check box.. i need to have stagename dynamically based of selection of check box