You need to sign in to do that
Don't have an account?
Justin Ruck
Dynamic Table not Pulling Back Data
I'm designing a leaderboard in VF that will bring back a table with either the top users with won opps, the top users for all ops, and the top users with tasks. It's one table, but the type of data listed will be determined by a drop down, called selectedVal. I've verified that I do have data there that should be pulling in, but there is no data that pulls through. Would you please let me know what might fix this issue?
Controller:
VF page:
Controller:
public class LeaderboardsController { public list<AggregateResult> EntireList = new list<AggregateResult>(); public list<allList> Top10List { get; private set; } public String OwnedBy { get; private set; } public Integer Amount { get; private set; } public LeaderboardsController() { //chart data if (selectedVal == 'Top Won Opportunity Sales Leaders') { EntireList = [select Owned_By__c owner, sum(AMOUNT) amt from Opportunity where CloseDate = THIS_FISCAL_QUARTER and StageName = 'Closed Won' group by Owned_By__c ORDER BY sum(Amount) DESC LIMIT 10]; for (AggregateResult ar : EntireList) System.debug(ar.get('owner')+'-'+ar.get('amt')); } else if (selectedVal == 'Top Opportunity Sales Leaders') { EntireList = [select Owned_By__c owner, sum(AMOUNT) amt from Opportunity where CREATEDDATE = THIS_FISCAL_QUARTER group by Owned_By__c ORDER BY sum(Amount) DESC LIMIT 10]; for (AggregateResult ar : EntireList) System.debug(ar.get('owner')+'-'+ar.get('amt')); } else if (selectedVal == 'Top Meeting Leaders') { EntireList = [select OwnerID owner, count(Subject) amt from Task where CreatedDate = THIS_FISCAL_QUARTER and ActivityType__c = 'Meeting' group by OwnerID ORDER BY count(Subject) DESC LIMIT 10]; for (AggregateResult ar : EntireList) System.debug(ar.get('owner')+'-'+ar.get('amt')); } else return; Top10List = new List<allList>(); for (AggregateResult ar : EntireList) { Top10List.add(new allList(ar)); } } //wrapper public class allList { public String OwnedBy { get; private set; } public Integer Amount { get; private set; } public allList(AggregateResult ar) { this.OwnedBy = String.valueOf(ar.get('owner')); this.Amount = Integer.valueOf(ar.get('amt')); } } //drop down boxes public String selectedVal{get;set;} // This will hold the selected value, the id in here public List<SelectOption> getopenPresentationOptions(){ List<SelectOption> optns = new List<Selectoption>(); optns.add(new SelectOption('Top Won Opportunity Sales Leaders','Top Won Opportunity Sales Leaders')); optns.add(new SelectOption('Top Opportunity Sales Leaders','Top Opportunity Sales Leaders')); optns.add(new SelectOption('Top Meeting Leaders','Top Meeting Leaders')); return optns; } public String selectedCountry{get;set;} // This will hold the selected value, the id in here public List<SelectOption> getopenCountryOptions(){ List<SelectOption> optns = new List<Selectoption>(); optns.add(new SelectOption('ALL','All')); optns.add(new SelectOption('US Distribution','US Distribution')); optns.add(new SelectOption('CA Distribution','CA Distribution')); optns.add(new SelectOption('Contract','Contract')); optns.add(new SelectOption('Manufacturing','Manufacturing')); optns.add(new SelectOption('US Retail','US Retail')); return optns; } public String selectedRegion{get;set;} // This will hold the selected value, the id in here public List<SelectOption> getopenRegionOptions(){ List<SelectOption> optns = new List<Selectoption>(); if(selectedCountry == 'US Distribution') { optns.add(new SelectOption('All','All')); optns.add(new SelectOption('Atlantic US','Atlantic US')); optns.add(new SelectOption('Mid West','Mid West')); optns.add(new SelectOption('South East','South East')); optns.add(new SelectOption('South West','South West')); optns.add(new SelectOption('West','West')); } else if(selectedCountry == 'CA Distribution') { optns.add(new SelectOption('All','All')); optns.add(new SelectOption('Atlantic Canada','Atlantic Canada')); optns.add(new SelectOption('BC','BC')); optns.add(new SelectOption('Head Office','Head Office')); optns.add(new SelectOption('Ontario','Ontario')); optns.add(new SelectOption('Prairies','Prairies')); optns.add(new SelectOption('Quebec','Quebec')); } else if(selectedCountry == 'Contract') { optns.add(new SelectOption('All','All')); } else if(selectedCountry == 'Manufacturing') { optns.add(new SelectOption('All','All')); } else if(selectedCountry == 'US Retail') { optns.add(new SelectOption('All','All')); } else { optns.add(new SelectOption('All','All')); } return optns; } }
VF page:
<apex:page controller="LeaderboardsController" title="Leaderboards" readonly="false"> <apex:form > <apex:selectList value="{!selectedVal}" size="1"> <apex:selectOptions value="{!openPresentationOptions}" /> <apex:actionSupport event="onchange" reRender="b"/> </apex:selectList> <apex:selectList value="{!selectedCountry}" size="1"> <apex:selectOptions value="{!openCountryOptions}" /> <apex:actionSupport event="onchange" reRender="a,b"/> </apex:selectList> <apex:selectList value="{!selectedRegion}" size="1" id="a"> <apex:selectOptions value="{!openRegionOptions}" /> <apex:actionSupport event="onchange" reRender="b"/> </apex:selectList> </apex:form> <br/> <br/> <apex:pageBlock id="b"> <apex:variable var="rowcount" value="{!1}" /> <apex:pageBlockTable value="{!Top10List}" var="ar" > <apex:column > {!rowcount} <apex:variable var="rowcount" value="{!rowcount+1}" /> </apex:column> <apex:column value="{!ar.OwnedBy}" headerValue="User"/> <apex:column style="text-align:right" headerClass="CurrencyElement"> <apex:facet name="header"><b>Total</b></apex:facet> <apex:outputText value="${0, number, ###,###,##0}"> <apex:param value="{!ar.Amount}"/> </apex:outputText> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
- Add some System.Debug statements in there to see if anything is coming back from the queries
- Run those AggregateQuery statements manually in your query tool of choice to see if anything does come back
There could be a few wonky things - Sharing Rules, Roles, etc. that may be creating issues, but deconstruct your code and make sure that the basic blocks are bringing back data first.Anybody else have any thoughts on this issue?
to
I get results for that data set. But the data is supposed to populate when the user selects Top Won Opportunity Sales Leaders from the picklisted "selectedVal". What could the issue be?