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
Hemalatha  ParuchuriHemalatha Paruchuri 

How to display AggregateResult Of 2 fields in custom object

Hi,

I have a custom object My__order__c and lookup to Account(Customer__c). In my order object have a field like Transaction ID.
In my order object have so many orders that means one account have multiple orders ..based on that they have Transaction ID and one more field is like net total__c.
my question is i have to display customer name,Transion id,net total but in that customer name i got customer id..so how can i get custome name(Account name).

Visualforce page:

<apex:page standardController="my_order__c" sidebar="false" extensions="Totalorders">
 <apex:form >
 <apex:pageBlock >
 
 <apex:pageBlockTable value="{!results}" var="r">
  <apex:column value="{!r['Customer__c']}">

  <apex:facet name="header">CustomerID</apex:facet>

 </apex:column>
 


   <apex:column value="{!r['Transaction_ID__c']}" >
<apex:facet name="header">Transaction ID</apex:facet>
   </apex:column>
                        
     <apex:column value="{!r['Total']}">
      <apex:facet name="header">Net Total </apex:facet>
    </apex:column>
                                    
  </apex:pageBlockTable>
 
 </apex:pageBlock>
 
 </apex:form>
 
 </apex:page>


Extension :

public with sharing class Totalorders {

  public Totalorders(ApexPages.StandardController controller) {
 
 }
     public AggregateResult[] results {
        get {
            return [select Transaction_ID__c,Customer__c,Sum(Net_Total__c)Total From my_order__c GROUP BY Rollup(Transaction_ID__c,Customer__c)];
        }
    }

 
 }
SandhyaSandhya (Salesforce Developers) 
Hi Hemalatha Paruchuri,

In your visual force page you need to use
Customer__r.Name instead of Customer__c
Hope this helps you!

If this solves your questions please mark it as solved.

Thanks and Regards
Sandhya