I am trying to display a pageBlockTable with my AggregateResult and then have a total in the footer of a column. I found a possible answer here, however the code gives me an error.
The error appears on the last line of my Apex. It is saying that the '=', ')', and the ";" on that last line are unexpected tokens. I ran this exact code block in execute anonymous (adding in system.debug and substituting an actual Id) and it ran with no issue.
Here is the Apex:
public class julAugPromos {
Public list<AggregateResult> japrom;
public julAugPromos(ApexPages.StandardController stdController){
japrom = [select report_description__c RDesc, SUM(qty_shipped__c) Quantity, SUM(Total_Sale_Amount__c) Total
from invitem__c
where cust_num__c = :ApexPages.currentPage().getParameters().get('id')
and sales_cat__c = 'PROM'
and inv_date__c >= 2017-06-15
and inv_date__c <= 2017-08-14
Group by report_description__c
Order by SUM(Total_Sale_Amount__c) desc];
}
public list<AggregateResult> japromlist {
get { return japrom;}
}
public double endtotal{get;set;}
AggregateResult[] tot
= [select SUM(Total_Sale_Amount__c)Gtot from invitem__c
where cust_num__c = :ApexPages.currentPage().getParameters().get('id')
and sales_cat__c = 'PROM'
and inv_date__c >= 2017-06-15
and inv_date__c <= 2017-08-14];
Object sumAmount = tot [0].get('Gtot');
endtotal=(double)sumAmount;
}
And here is the VF:
<apex:page standardController="Account" tabStyle="Account" extensions="julAugPromos">
<apex:pageBlock title="Jul-Aug 2017 Promos" tabStyle="Account">
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!japromlist}" var="o">
<apex:column >
<apex:facet name="header">Product Description</apex:facet>
{!o['RDesc']}</apex:column>
<apex:column >
<apex:facet name="header">Qty Sold</apex:facet>
{!o['Quantity']}</apex:column>
<apex:column >
<apex:facet name="footer">{!endTotal} </apex:facet>
<apex:facet name="header">Total Sales</apex:facet>
{!o['Total']}</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
Any help would be greatly appreciated!