You need to sign in to do that
Don't have an account?
Andrew Aldis 6
Creating Sub-Tables
I am trying to create a VF page to display on the account page I have an installation object account__r which is a child of account, I also have a Hardware Information object that is a child object of the Installation object. I would like to create a VF page that displays a pageblock table of the installations and under each installation an expandable sub-table that displays the hardware information records. I wrote the VF page below and get the following error. Anyone want to help out a newby on getting this done?
My Error:
Object type not accessible. Please check permissions and make sure the object is not in development mode: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object.. Original queryString was: 'SELECT (SELECT (SELECT Carrier_for_Shipment__c, Id, Item_Master__c, Quantity_Ordered__c, Quantity_Shipped__c, Sales_Order__c, Sales_Order_Line_Item__c, Serial_Number_Shipped_from_Denver_Whs__c, Ship_Date__c, Ship_to_Address__c, Shipment_Type__c, Tracking_Number__c FROM Hardware_Information__r), Id, Name, SFDC_Project_Manager__c, SFDC_Project_Name__c, SFDC_Project_Status__c FROM account__r), Id FROM Account WHERE id = '000000000000000''
My Code:
<apex:page standardController="Account">
<apex:pageBlock >
<apex:pageBlockTable value="{!Account.account__r}" var="install">
<apex:column value="{!install.Name}"/>
<apex:column value="{!install.SFDC_Project_Manager__c}"/>
<apex:column value="{!install.SFDC_Project_Name__c}"/>
<apex:column value="{!install.SFDC_Project_Status__c}"/>
<apex:column breakBefore="True" colspan="2"/>
<apex:pageBlockSection title="Hardware Shipment Information" showHeader="true" collapsible="True">
<apex:pageBlockTable value="{!install.Hardware_Information__r}" var="hardware">
<apex:column value="{!hardware.Shipment_Type__c}"/>
<apex:column value="{!hardware.Ship_Date__c}"/>
<apex:column value="{!hardware.Item_Master__c}"/>
<apex:column value="{!hardware.Sales_Order__c}"/>
<apex:column value="{!hardware.Sales_Order_Line_Item__c}"/>
<apex:column value="{!hardware.Serial_Number_Shipped_from_Denver_Whs__c}" />
<apex:column value="{!hardware.Quantity_Ordered__c}"/>
<apex:column value="{!hardware.Quantity_Shipped__c}"/>
<apex:column value="{!hardware.Carrier_for_Shipment__c}"/>
<apex:column value="{!hardware.Tracking_Number__c}"/>
<apex:column value="{!hardware.Ship_to_Address__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
My Error:
Object type not accessible. Please check permissions and make sure the object is not in development mode: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object.. Original queryString was: 'SELECT (SELECT (SELECT Carrier_for_Shipment__c, Id, Item_Master__c, Quantity_Ordered__c, Quantity_Shipped__c, Sales_Order__c, Sales_Order_Line_Item__c, Serial_Number_Shipped_from_Denver_Whs__c, Ship_Date__c, Ship_to_Address__c, Shipment_Type__c, Tracking_Number__c FROM Hardware_Information__r), Id, Name, SFDC_Project_Manager__c, SFDC_Project_Name__c, SFDC_Project_Status__c FROM account__r), Id FROM Account WHERE id = '000000000000000''
My Code:
<apex:page standardController="Account">
<apex:pageBlock >
<apex:pageBlockTable value="{!Account.account__r}" var="install">
<apex:column value="{!install.Name}"/>
<apex:column value="{!install.SFDC_Project_Manager__c}"/>
<apex:column value="{!install.SFDC_Project_Name__c}"/>
<apex:column value="{!install.SFDC_Project_Status__c}"/>
<apex:column breakBefore="True" colspan="2"/>
<apex:pageBlockSection title="Hardware Shipment Information" showHeader="true" collapsible="True">
<apex:pageBlockTable value="{!install.Hardware_Information__r}" var="hardware">
<apex:column value="{!hardware.Shipment_Type__c}"/>
<apex:column value="{!hardware.Ship_Date__c}"/>
<apex:column value="{!hardware.Item_Master__c}"/>
<apex:column value="{!hardware.Sales_Order__c}"/>
<apex:column value="{!hardware.Sales_Order_Line_Item__c}"/>
<apex:column value="{!hardware.Serial_Number_Shipped_from_Denver_Whs__c}" />
<apex:column value="{!hardware.Quantity_Ordered__c}"/>
<apex:column value="{!hardware.Quantity_Shipped__c}"/>
<apex:column value="{!hardware.Carrier_for_Shipment__c}"/>
<apex:column value="{!hardware.Tracking_Number__c}"/>
<apex:column value="{!hardware.Ship_to_Address__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Thanks,
Neetu
All Answers
You cannot query more than 1 level as it is salesforce force limitation, well I have one solution for you:
List<Account__c> accounts = [ Select Id, Name, SFDC_Project_Manager__c, SFDC_Project_Name__c, SFDC_Project_Status__c, (SELECT Carrier_for_Shipment__c, Id, Item_Master__c, Quantity_Ordered__c, Quantity_Shipped__c, Sales_Order__c, Sales_Order_Line_Item__c, Serial_Number_Shipped_from_Denver_Whs__c, Ship_Date__c, Ship_to_Address__c, Shipment_Type__c, Tracking_Number__c FROM Hardware_Information__r) FROM Account__c where Account = '000000000000000']; //specify the account Id
This list must be getter properties:
Now on the page use these lists:
<apex:page standardController="Account">
<apex:pageBlock >
<apex:pageBlockTable value="{!accounts}" var="install">
<apex:column value="{!install.Name}"/>
<apex:column value="{!install.SFDC_Project_Manager__c}"/>
<apex:column value="{!install.SFDC_Project_Name__c}"/>
<apex:column value="{!install.SFDC_Project_Status__c}"/>
<apex:column breakBefore="True" colspan="2"/>
<apex:pageBlockSection title="Hardware Shipment Information" showHeader="true" collapsible="True">
<apex:pageBlockTable value="{!install.Hardware_Information__r}" var="hardware">
<apex:column value="{!hardware.Shipment_Type__c}"/>
<apex:column value="{!hardware.Ship_Date__c}"/>
<apex:column value="{!hardware.Item_Master__c}"/>
<apex:column value="{!hardware.Sales_Order__c}"/>
<apex:column value="{!hardware.Sales_Order_Line_Item__c}"/>
<apex:column value="{!hardware.Serial_Number_Shipped_from_Denver_Whs__c}" />
<apex:column value="{!hardware.Quantity_Ordered__c}"/>
<apex:column value="{!hardware.Quantity_Shipped__c}"/>
<apex:column value="{!hardware.Carrier_for_Shipment__c}"/>
<apex:column value="{!hardware.Tracking_Number__c}"/>
<apex:column value="{!hardware.Ship_to_Address__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Thanks,
Neetu
yes the list will go to page but you have to specify the page extenstion like:
<apex:page standardController="Account" extensions="Your Class Name" >
Thanks,
Neetu
Try this:
public with sharing class AccountController
{
public List<Account__c> accounts { get; set; }
/**
* Name: Parameterised Constructor
* Desc: To initialize values
**/
public AccountController(ApexPages.StandardController stdcontroller)
{
// To get the account record
Account acc = (Account)stdController.getRecord();
if( acc != null )
{
accounts = [ Select Id, Name, SFDC_Project_Manager__c, SFDC_Project_Name__c, SFDC_Project_Status__c,
(SELECT Carrier_for_Shipment__c, Id, Item_Master__c, Quantity_Ordered__c, Quantity_Shipped__c, Sales_Order__c,
Sales_Order_Line_Item__c, Serial_Number_Shipped_from_Denver_Whs__c, Ship_Date__c, Ship_to_Address__c,
Shipment_Type__c, Tracking_Number__c FROM Hardware_Information__r)
FROM Account__c where Account =: acc.Id ];
}
}
<apex:page standardController="Account" extensions="AccountController">
<apex:pageBlock >
<apex:pageBlockTable value="{!accounts}" var="install">
<apex:column value="{!install.Name}"/>
<apex:column value="{!install.SFDC_Project_Manager__c}"/>
<apex:column value="{!install.SFDC_Project_Name__c}"/>
<apex:column value="{!install.SFDC_Project_Status__c}"/>
<apex:column breakBefore="True" colspan="2"/>
<apex:pageBlockSection title="Hardware Shipment Information" showHeader="true" collapsible="True">
<apex:pageBlockTable value="{!install.Hardware_Information__r}" var="hardware">
<apex:column value="{!hardware.Shipment_Type__c}"/>
<apex:column value="{!hardware.Ship_Date__c}"/>
<apex:column value="{!hardware.Item_Master__c}"/>
<apex:column value="{!hardware.Sales_Order__c}"/>
<apex:column value="{!hardware.Sales_Order_Line_Item__c}"/>
<apex:column value="{!hardware.Serial_Number_Shipped_from_Denver_Whs__c}" />
<apex:column value="{!hardware.Quantity_Ordered__c}"/>
<apex:column value="{!hardware.Quantity_Shipped__c}"/>
<apex:column value="{!hardware.Carrier_for_Shipment__c}"/>
<apex:column value="{!hardware.Tracking_Number__c}"/>
<apex:column value="{!hardware.Ship_to_Address__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Thanks,
Neetu
Thanks,
Neetu
What issue you are facing now.
Thanks,
Neetu
This is what I have
public with sharing class hardwareShippingSerialNumbers {
public List<SFDC_Project__c> installs { get; set; }
/**
* Name: Parameterised Constructor
* Desc: To initialize values
**/
public AccountController(ApexPages.StandardController stdcontroller)
{
// To get the install record
install ins = (install)stdController.getRecord();
if( ins != null )
{
installs = [ Select Id,
(SELECT Id, Installation__c, SCMC__Serial_Number__c, Shipment_Date_Time__c, Warranty_Level__c,
Warranty_Expiration_Date1__c FROM Serial_Number__r )
FROM SFDC_Project__c where install=ins.Id];
}
}}