You need to sign in to do that
Don't have an account?

AggregateResults and Currency Fields
Hi All,
I am struggling to return the value of a field as a two decimal place field i.e. currency fields back to my VF page.
Here is my class:
With decimal I get the error: Variable does not exist: decimal at line 87
Any help is appreciated.
Thanks
I am struggling to return the value of a field as a two decimal place field i.e. currency fields back to my VF page.
Here is my class:
public class ESDCDA { private final Opportunity opp; public ESDCDA(ApexPages.StandardController stdController) { this.opp = (Opportunity)stdController.getRecord(); } double eop; double op; list<AggregateResult> aK; transient public double total {get; set;} transient public decimal oppr {get; set;} transient public decimal losm {get; set;} transient public decimal mc {get; set;} transient public decimal dcc {get; set;} transient public decimal ssp {get; set;} transient public decimal ans {get; set;} public void showlist(){ aK=[select mpan__c, siteaddress__c, Site_Contact__c, Site_Telephone_Number__c, Sub_Product__c, sum(on_supply_service_charge__c)ossc, InvoiceAddress__c from es_mpan__c where opportunity_name__c =:opp.id group by mpan__c, siteaddress__c, Site_Contact__c, Site_Telephone_Number__c, Sub_Product__c, InvoiceAddress__c]; if(opp.ES_Opportunity_2__c != Null){ aggregateResult[]aK1 = [select mpan__c, siteaddress__c, Site_Contact__c, Site_Telephone_Number__c, Sub_Product__c, InvoiceAddress__c, sum(on_supply_service_charge__c)ossc from es_mpan__c where opportunity_name__c = :opp.ES_Opportunity_2__c group by mpan__c, siteaddress__c, Site_Contact__c, Site_Telephone_Number__c, Sub_Product__c, InvoiceAddress__c]; ak.addAll(ak1); AggregateResult[] t = [select sum(Total_Annual_Charges__c)tc, sum(es_opportunity_2__r.Total_Annual_Charges__c)etc from opportunity where id =:opp.id]; if(double.valueof(t[0].get('tc')) == Null){op = 0.00;}else{op = double.valueof(t[0].get('tc'));} if(double.valueof(t[0].get('etc')) == Null){eop = 0.00;}else{eop = double.valueof(t[0].get('etc'));} total = op + eop; }else{ AggregateResult[] t = [select sum(Total_Annual_Charges__c)tc from opportunity where id =:opp.id]; op = double.valueof(t[0].get('tc')); total = op; AggregateResult[] sm = [select sum(Outright_Purchase_Price__c)oppr, sum(Lease_of_Secondary_Metering__c)losm, sum(Maintenance_Charge__c)mc, sum(Data_Collection_Charge__c)dcc, sum(Supply_Software_Package__c)ssp, sum(Ancillary_Services__c)ans from es_mpan__c where opportunity_name__c =:opp.id]; oppr = decimal.valueof(sm[0].get('oppr')); losm = decimal.valueof(sm[0].get('losm')); mc = decimal.valueof(sm[0].get('mc')); dcc = decimal.valueof(sm[0].get('dcc')); ssp = decimal.valueof(sm[0].get('ssp')); ans = decimal.valueof(sm[0].get('ans')); } } public list<AggregateResult> jalist{ get { return aK;} } }If I use double I only get one decimal place unless the field was entered with two i.e. 10.25 will return 10.25 but 10 return 10.0
With decimal I get the error: Variable does not exist: decimal at line 87
Any help is appreciated.
Thanks
Resolved it in Visualforce instead using:
<apex:outputText value="{0, number, £###,###,###,###,##0.00}"> <apex:param value="{!oppr}"/> </apex:outputText>
Go me!