You need to sign in to do that
Don't have an account?
Hemalatha 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)];
}
}
}
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)];
}
}
}
In your visual force page you need to use Hope this helps you!
If this solves your questions please mark it as solved.
Thanks and Regards
Sandhya