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

Aggregate result error message
Help please,
The erro message is List has more than 1 row for assignment to SObject error
I test the SOQL query in developer Console, and work as expected But, i get error message in the VF
My Controller is:
public class InventoryReport {
public List<Articles_Containers__c> allproduct{get;set;}
public InventoryReport() {
AggregateResult allproduct = [
SELECT Product_Hiden_Name__c, UM__c ,SUM(On_Hand__c)onHand, SUM(Pending__c)pending, SUM(Available__c)avail
FROM Articles_Containers__c
GROUP BY Product_Hiden_Name__c , UM__c
HAVING SUM(On_Hand__c)>0
ORDER BY Product_Hiden_Name__c, UM__c
limit 1000];
}
}
VF Page is:
<apex:page controller="InventoryReport" showHeader="true" RenderAs="PDF">
<div class="table">
<div class="tableHeader">
<th>Item</th>
<th>Unit Of Measure </th>
<th>On Hand </th>
<th>Pendig </th>
<th>Available </th>
</div>
<apex:repeat value="{!allproduct}" var="a"> <!-- <div class="tablebody"> -->
<tr>
<td>{!a.Product_Hiden_Name__c }</td>
<td>{!a.UM__c}</td>
<td>{!a['onHand']}</td>
<td>{!a.['Pending']}</td>
<td>{!a.['avail']}</td>
</tr>
</apex:repeat> </div>
</apex:page>
The erro message is List has more than 1 row for assignment to SObject error
I test the SOQL query in developer Console, and work as expected But, i get error message in the VF
My Controller is:
public class InventoryReport {
public List<Articles_Containers__c> allproduct{get;set;}
public InventoryReport() {
AggregateResult allproduct = [
SELECT Product_Hiden_Name__c, UM__c ,SUM(On_Hand__c)onHand, SUM(Pending__c)pending, SUM(Available__c)avail
FROM Articles_Containers__c
GROUP BY Product_Hiden_Name__c , UM__c
HAVING SUM(On_Hand__c)>0
ORDER BY Product_Hiden_Name__c, UM__c
limit 1000];
}
}
VF Page is:
<apex:page controller="InventoryReport" showHeader="true" RenderAs="PDF">
<div class="table">
<div class="tableHeader">
<th>Item</th>
<th>Unit Of Measure </th>
<th>On Hand </th>
<th>Pendig </th>
<th>Available </th>
</div>
<apex:repeat value="{!allproduct}" var="a"> <!-- <div class="tablebody"> -->
<tr>
<td>{!a.Product_Hiden_Name__c }</td>
<td>{!a.UM__c}</td>
<td>{!a['onHand']}</td>
<td>{!a.['Pending']}</td>
<td>{!a.['avail']}</td>
</tr>
</apex:repeat> </div>
</apex:page>
Thank, let us know if it helps you
All Answers
Thank, let us know if it helps you