You need to sign in to do that
Don't have an account?
Jeremy Deseez
Value of Picklist send to Controller to change a SOQL
Hi SFDC, I'm new in the Apex world :)
I have some trouble with picklist value, i will explain.
I have a picklist that show me the StartDate from the Period Objects.
I have also a List of ForecastingQuota by User.
The problem is that when I select a value in the picklist, the controller doesn't get it, so my query wich show the user can't change.
Controller :
And the VFP code :
Thank's for the help :)
I have some trouble with picklist value, i will explain.
I have a picklist that show me the StartDate from the Period Objects.
I have also a List of ForecastingQuota by User.
The problem is that when I select a value in the picklist, the controller doesn't get it, so my query wich show the user can't change.
Controller :
public List<SelectOption> optionspl {get;set;} public List<User> resultsusers{get;set;} public Date dateinput{get;set;} public Date dateinput2 {get;set;} public List<SelectOption> getPeriodList(){ List<SelectOption> optionspl = new List<SelectOption>(); List<SObject> resultspl = [SELECT FullyQualifiedLabel, StartDate FROM Period WHERE StartDate > TODAY AND Type = 'Quarter']; for(SObject pl : resultspl){ optionspl.add(new SelectOption(String.valueOf(pl.get('StartDate')),String.valueOf(pl.get('StartDate')))); } return optionspl; } public List<ForecastingQuota> getAllQuotas(){ dateinput = Date.today(); date mydate2 = mydate.addDays(90); List<ForecastingQuota> resultsquotas = new List<ForecastingQuota>(); resultsquotas = [SELECT Id,QuotaAmount,QuotaOwnerId, StartDate FROM ForecastingQuota WHERE StartDate >:dateinput AND StartDate <:mydate2 ORDER BY QuotaOwnerId, StartDate ASC]; List<User> resultsusers = new List<User>(); resultsusers = [SELECT Id FROM User WHERE IsActive = TRUE AND ForecastEnabled = TRUE LIMIT 999]; Map<Id, ForecastingQuota> fqsByOwnerId = new Map<Id, ForecastingQuota>(); for (ForecastingQuota fq : resultsquotas) { fqsByOwnerId.put(fq.QuotaOwnerId, fq); } // new map of quotas keyed by all user ids Map<Id, ForecastingQuota> allUserFqsByOwnerId = new Map<Id, ForecastingQuota>(); for (User u : resultsusers) { allUserFqsByOwnerId.put(u.id, fqsByOwnerId.containsKey(u.id) ? fqsByOwnerId.get(u.id) : new ForecastingQuota(QuotaOwnerId = u.id, QuotaAmount = null)); } List<ForecastingQuota> allthequotas = new List<ForecastingQuota>(); allthequotas = allUserFqsByOwnerId.values(); allthequotas.sort(); return allthequotas; }
And the VFP code :
<apex:pageBlockSection columns="4"> <apex:selectList value="{!dateinput2}" id="dateinput2" size="1"> <apex:selectOptions value="{!periodlist}" /> <apex:actionSupport event="onchange" rerender="allquotas"/> </apex:selectList> <apex:pageBlockTable value="{!allquotas}" var="key"> <apex:column> <input type="checkbox" name="pouet"/> </apex:column> <apex:column headerValue="Name"> <apex:outputField value="{!key.QuotaOwnerId}"/> </apex:column> <apex:column headerValue="Quota"> <apex:inputField value="{!key.QuotaAmount}"/> </apex:column> <apex:column headerValue="Date"> <apex:outputField value="{!key.StartDate}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock>
Thank's for the help :)
<apex:actionSupport event="onchange" rerender="allquotas" action="{!getAllQuotas}"/>
you should also add an id to <apex:pageBlockTable ..id="allquotas" .. so it is rerendered.
Then the page will refresh and see if you get your updated table, if you do then it may help troubleshoot!