function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ttlttl 

Error in visualforce page when trying to populate the total sum using AggregateResult.

Hi guys,

 

I am getting error: Unknown property 'Accountscore_card.AccountSum.total1'  in my visualforce page.

My VisualForce page is as follow:-

 

<apex:page controller="Accountscore_card">

  <apex:form >

   <apex:pageBlock title="Account's spend on Telecom (Rs. Crore)">

   <apex:pageBlockSection title="Details" Id="NewCard">        

<apex:dataTable value="{!accountSumlist}" var="test" border="1" style="height:20;float: left;" id="stable">

          <apex:column headerValue="Wireline Voice" width="5px">

             <apex:outputText value="{!test.total1}" style="align: center" />

          </apex:column>

          <apex:column headerValue="Wireline Data" width="5px" >

              <apex:outputText value="{!test.total2}"/>

          </apex:column>

                    <apex:column headerValue="Wireless Voice" width="5px" >

             <apex:outputText value="{!test.total3}"/>

          </apex:column>

          <apex:column headerValue="Wireless Data" width="5px" >

             <apex:outputText value="{!test.total4}"/>

          </apex:column>

          <apex:column headerValue="Enterprise Solutions" width="5px" >

              <apex:outputText value="{!test.total5}"/>

          </apex:column>

     </apex:dataTable>

    </apex:pageBlockSection>

  </apex:pageBlock>

</apex:form>

</apex:page>

 

Controller is,

 

 

public class AccountScore_card{

public Double sum1{get;set;}  

public AggregateResult SumResults =

      [SELECT SUM(Account_Score__c.wireline_voice__c) total1,

        SUM(Account_Score__c.wireline_data__c) total2,

        SUM(Account_Score__c.wireless_voice__c) total3,

        SUM(Account_Score__c.wireless_data__c) total4,

        SUM(Account_Score__c.enterprise__c) total5

        FROM Account_Score__c where Account__c=:str];

 

    public class AccountSum {

 

     //public AccountSum(AggregateResult ar){} 

    } 

 public List<AccountSum> accountSumlist = new List<AccountSum>();

 public List<AccountSum> getAccountSumlist(){

    Map<String, String> KeyNames = new Map<String, String>();

    KeyNames.put('total1', 'wirelinevoice');

    KeyNames.put('total2', 'wirelinedata');

    KeyNames.put('total3', 'wirelessvoice');

    KeyNames.put('total4', 'wirelessdata');

    KeyNames.put('total5', 'enterprise');

 

    for (String key : KeyNames.keySet()) {

      AccountSum cs = new AccountSum();

      cs.sum1 = (Double) SumResults.get(key);

      accountSumList.add(cs);

      }

      return AccountSumList;

    }

}

 

 

guys please help me to resolve the issue.

any suggestion would be appreciated.

 

 

Thanks,

 

aballardaballard

What is the actual definition of your class AccountSum?  What you show here doesn't make sense... it has no members. 

 

ttlttl

Hi aballard,

 

I am new in salesforce  found this signature to use the aggregate Result. sorry,I misplaced variable Sum1, and declare variable Sum1 outside AccountSum class ,But in actual I declare it inside AccountSum.Guys, here i am trying to store the total sum of field(Ex:-Wireline Voice) into the  Sum1 , Inside the For loop I created the object of the AccountSum class and store total value there and added this object to the list,  Using this List I want to display all the Field Value in Visualforce.

 

My requirment is to display the total sum of Wireline Voice,WirelineData,Wireless Voice,Wireless data on visualforce page.

 

Abballard,if there will be another way to do this ,Please help me.

 

Thanks,

aballardaballard

your page is referencing a bunch of fields inAccountSum to access the datas.  But I don't see anything in yout controller to put the data there. 

 

ttlttl

Thanks aballard,

  For giving such a valuable time,Friend i declare Variable sum1 for storing the data of that field.what i do know in controller to resolve this issue.please suggest.