You need to sign in to do that
Don't have an account?
soql value comes in to null..
Hi,
soql value comes in to null. please correct the code.
class
public with sharing class SearchOpportunity {
List<Opportunity> listopp = new List<Opportunity>();
Public String Oppname;
public String valopp {get; set;}
public List<SelectOption> getOppname() {
List<SelectOption> options = new List<SelectOption>();
// options.add(new SelectOption('None','None'));
List<Opportunity> listpickOpp = new List<Opportunity>();
listpickOpp = [Select id,name from Opportunity];
for(Opportunity objopp : listpickOpp){
if(objopp.name != null){
options.add(new SelectOption(objopp.name,objopp.name));
}
}
return options;
}
public List<Opportunity> getresults() {
return listopp;
}
public PageReference Search(){
listopp =[select id,name,Stagename,Account.name,Amount,LeadSource,CloseDate__c,Probability,OpportunityCheck__c from Opportunity where name =:valopp]; --- value is null
PageReference packagePage = new PageReference('/apex/VFResult');
return(packagePage);
}
page
<apex:page controller="SearchOpportunity">
<apex:sectionHeader title="Opportunity Search" subtitle="Opportunity Search"/>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Opportunity Search" columns="7" collapsible="false">
<apex:outputLabel Value="Opportunity Name" style="margin-left:1%;font-weight:bold;position:relative;bottom:5px" >
<apex:selectList value="{!valopp}" size="1" style="margin-left:2%;position:relative;top:5px;">
<apex:selectOptions value="{!Oppname}"/>
</apex:selectList>
</apex:outputLabel>
<apex:commandButton value="Search" immediate="true" action="{!Search}" />
</apex:pageBlockSection>
<apex:pageBlock title="Search Results">
<apex:pageBlockTable value="{!results}" var="sc">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!sc.OpportunityCheck__c}"/>
</apex:column>
<apex:column headerValue="Opportunity Name" value="{!sc.Name}"/>
<apex:column headerValue="Account Name" value="{!sc.Account.Name}"/>
<apex:column headerValue="Lead Source" value="{!sc.LeadSource}"/>
<apex:column headerValue="Stagename" value="{!sc.Stagename}"/>
<apex:column headerValue="Amount" value="{!sc.Amount}"/>
<apex:column headerValue="Probability" value="{!sc.Probability}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
Hi,
You’re running code. I have remove the custom field that is created by you in your org please add them in query (Apex controller) and in repeat (VF page).
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
soql value comes in to null. please correct the code.
class
public with sharing class SearchOpportunity {
List<Opportunity> listopp = new List<Opportunity>();
Public String Oppname;
public String valopp {get; set;}
public List<SelectOption> getOppname() {
List<SelectOption> options = new List<SelectOption>();
// options.add(new SelectOption('None','None'));
List<Opportunity> listpickOpp = new List<Opportunity>();
listpickOpp = [Select id,name from Opportunity];
for(Opportunity objopp : listpickOpp){
if(objopp.name != null){
options.add(new SelectOption(objopp.name,objopp.name));
}
}
return options;
}
public List<Opportunity> getresults() {
return listopp;
}
public PageReference Search(){
listopp =[select id,name,Stagename,Account.name,Amount,LeadSource,CloseDate__c,Probability,OpportunityCheck__c from Opportunity where name =:valopp]; --- value is null
PageReference packagePage = new PageReference('/apex/VFResult');
return(packagePage);
}
page
<apex:page controller="SearchOpportunity">
<apex:sectionHeader title="Opportunity Search" subtitle="Opportunity Search"/>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Opportunity Search" columns="7" collapsible="false">
<apex:outputLabel Value="Opportunity Name" style="margin-left:1%;font-weight:bold;position:relative;bottom:5px" >
<apex:selectList value="{!valopp}" size="1" style="margin-left:2%;position:relative;top:5px;">
<apex:selectOptions value="{!Oppname}"/>
</apex:selectList>
</apex:outputLabel>
<apex:commandButton value="Search" immediate="true" action="{!Search}" />
</apex:pageBlockSection>
<apex:pageBlock title="Search Results">
<apex:pageBlockTable value="{!results}" var="sc">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!sc.OpportunityCheck__c}"/>
</apex:column>
<apex:column headerValue="Opportunity Name" value="{!sc.Name}"/>
<apex:column headerValue="Account Name" value="{!sc.Account.Name}"/>
<apex:column headerValue="Lead Source" value="{!sc.LeadSource}"/>
<apex:column headerValue="Stagename" value="{!sc.Stagename}"/>
<apex:column headerValue="Amount" value="{!sc.Amount}"/>
<apex:column headerValue="Probability" value="{!sc.Probability}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
Hi,
You have to remove immediate="true" or make its value as false from apex: commandButton. Instead use this only and it will work for you:
<apex:commandButton value="Search" action="{!Search}"/>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Just change your visualforce page command button code from :
To :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thanks
If i remove immediate= true , command button is not working.
Please do not post the same content in multiple sections. I have merged both duplicate topics.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Hi,
You’re running code. I have remove the custom field that is created by you in your org please add them in query (Apex controller) and in repeat (VF page).
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Thanks...