Skip to main content
I'm trying to pick up aggregated information from two different aggregatedlist and at the end , I want to subtract those information that came from different objects.

 

This is my code:

 

 

public class Containers {

private final Container__c acct;

private list<AggregateResult> resellers;

private list<AggregateResult> resellers1;

public Decimal recei {get; set;}

public Decimal total {get; set;}

public String name {get; set;}

public Containers(ApexPages.StandardController stdController){

this.acct = [select id, name from Container__c where id=:ApexPages.currentPage().getParameters().get('id')];

resellers1 = [SELECT SUM(Received__c) rec,Product__r.Name rname FROM Receivable__c

where Container_lookup__c = :this.acct.id GROUP BY Product__r.Name];

for(AggregateResult dec: resellers1){

for (Integer i=0;i < resellers1.size(); i++){

Decimal recei = (Decimal)resellers1[i].get('rec');

String name = (String)resellers1[i].get('rname');

break;

}

}

resellers = [SELECT SUM(Quantity) tot ,Product2.Name Id, MAX(Inventory__r.Total_On_Hand__c) hand FROM OpportunityLineItem

where Container__c = :this.acct.id GROUP BY Product2.Name];

for(AggregateResult dec: resellers){

for (Integer i=0;i < resellers.size(); i++){

Decimal total = (Decimal)resellers[i].get('tot');

break;

}

}

}

public list<AggregateResult> resellerlist {

get { return resellers;}

}

public list<AggregateResult> resellerlist1 {

get { return resellers1;}

}

}

 

and this is my VF:

<apex:page standardController="Container__c" extensions="Containers" lightningStylesheets="true">

<apex:form >

<apex:pageblock >

<apex:pageBlockSection title="Sales">

<apex:pageBlockTable value="{!resellerlist}" var="o">

<apex:column >

<apex:facet name="header">Product Name</apex:facet>

{!o['Id']}</apex:column>

<apex:column >

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

{!o['tot']}</apex:column>

<apex:column >

<apex:facet name="header">Inventory On Hand</apex:facet>

{!o['hand']}</apex:column>

</apex:pageBlockTable>

</apex:pageBlockSection>

<apex:pageBlockSection title="Receivables">

<apex:pageBlockTable value="{!resellerlist1}" var="o">

<apex:column >

<apex:facet name="header">Product Name</apex:facet>

{!o['rname']}</apex:column>

<apex:column >

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

{!o['rec']}</apex:column>

 

That's what I basically want;

 

I'm trying to create a aggregate list that will combine two info from different objects​​​​​​​
1 respuesta
0/9000