You need to sign in to do that
Don't have an account?
Problem getting AgreggateResult from the list
Hi all,
I have a problem getting the value from an AgreggateResult returned by an SOQL. Here is the code from the SOQL:
total = [SELECT SUM(Total_Net__c)tmp FROM Selected_Product__c WHERE Service_Reservation__c =:servOrder GROUP BY Service_Reservation__c]; system.debug('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'+total);
That system.debug gives me this:
16:17:01:123 USER_DEBUG [24]|DEBUG|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%(AggregateResult:{tmp=40.0})
Which is the value I want to show. In a different method I try to return 'result' as integer this way:
public integer result {get; set;} ... public integer getResult(){ integer result; for(AggregateResult ar:total){ result = (integer)ar.get('tmp'); system.debug('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'+result); } return result; }
NOTE: When I debug this it never gets to the system.debug, but salesforce allows me to save this code (hence, no syntax errors).
And in the VF page I call for result this way:
<apex:outputText value="{!result}"/>
And no result at all (empty).
Do you have any idea of why this is happening?. Any solution?
Many thanks,
MGA.
change result to decimal
Hi,
It didn't work. The same problem.
Any other guess?
Could you share your debug log?
Sure. Here you
:
I am not able to see
in the debug log, have you removed it or is the getResult() function not being called?
Hi,
The code is still there, I didn't remove anything. I think it is not called at all.
MGA.