You need to sign in to do that
Don't have an account?
Apex Error: SObject row was retrieved via SOQL without querying the requested field:
SUMMARY
I have signed up for the Salesforce Partner Program and have created a managed app called ABC Company using my Partner Developer Edition account (dev org).
The app consists of one parent custom object (Project__c) and two child custom objects (Sent_item__c & Received_item__c).
I have a visualforce PDF page that displays the Project Summary with the Sent and Received related lists. For this VF PDF Page I have created an Apex Class that sorts/orders the list by Name ASC for Sent and Received Related Lists. I also have an apex test class with 100% code coverage.
The Generate Visualforce PDF Page works without any problems in my Partner Developer Edition account (dev org).
PROBLEM
After successful installation of my app on my Enterprise/Platform Edition account (Test Org) as a managed app I receive the following error when I try to generate the VF page:
common.apex.runtime.impl.ExecutionException: SObject row was retrieved via SOQL without querying the requested field:ecpfinal__Project__c.Name
(The error only occurs in my managed solution when installed on another Enterprise/Platform Edition account (Test Org))
Can you provide the necessary code to fix this error? Do I need to add additional code to the apex class?
I am available through Skype and would like to drop in the code in real time through Skype with screen share or another similar method..
VISUALFORCE PDF PAGE (Project_Summary) <apex:page standardController="Project__c" sidebar="false" showHeader="false" renderAs="pdf" extensions="ProjectSummaryPDFController"> <hr></hr> <h3>PROJECT SUMMARY</h3> <hr></hr> <table style="width: 100%;"> <tr><td style="width: 25%;">Project Number:</td><td style="width: 75%;">{!Project__c.Name}</td></tr> <tr><td style="width: 25%;">Project Name:</td><td style="width: 75%;">{!Project__c.Project_Name__c}</td></tr> <tr><td style="width: 25%;">Contractor:</td><td style="width: 75%;">{!Project__c.Contractor__c}</td></tr> </table> <hr></hr> <b>SENT ITEMS</b> <hr></hr> <apex:dataTable value="{!cvSentItemLineItemsSorted}" var="item" border="1" cellpadding="3" width="100%" > <apex:column > <apex:facet name="header">Item Number</apex:facet> <apex:outputText value="{!item.Name}"/> </apex:column> <apex:column > <apex:facet name="header">Description</apex:facet> <apex:outputText value="{!item.Description__c}"/> </apex:column> </apex:datatable> <hr></hr> <b>RECIEVED ITEMS</b> <hr></hr> <apex:dataTable value="{!cvReceivedItemLineItemsSorted}" var="item" border="1" cellpadding="3" width="100%" > <apex:column > <apex:facet name="header">Item Number</apex:facet> <apex:outputText value="{!item.Name}"/> </apex:column> <apex:column > <apex:facet name="header">Description</apex:facet> <apex:outputText value="{!item.Description__c}"/> </apex:column> </apex:datatable> <hr></hr> </apex:page> APEX CLASS public with sharing class ProjectSummaryPDFController { //set up the class variables we'll need to reference from VF page public List<Sent_item__c> cvSentItemLineItemsSorted {public get; private set;} public List<Received_item__c> cvReceivedItemLineItemsSorted {public get; private set;} //variable to hold current Project__c record private Project__c cvSelectedProject = null; //constructor public ProjectSummaryPDFController(ApexPages.StandardController pCntrllr) { // grab current Project__c record from the Standard Controller cvSelectedProject = (Project__c)pCntrllr.getRecord(); // build sorted List of Sent_item__c records for current Project__c cvSentItemLineItemsSorted = new List<Sent_item__c>(); cvSentitemLineItemsSorted = [Select item.Name, item.Description__c From Sent_item__c item Where item.Project_Number__c =: cvSelectedProject.id ORDER BY item.Name ASC limit 1000]; // build sorted List of Received_item__c records for current Project__c cvReceivedItemLineItemsSorted = new List<Received_item__c>(); cvReceivedItemLineItemsSorted = [Select item.Name, item.Description__c From Received_item__c item Where item.Project_Number__c =: cvSelectedProject.id ORDER BY item.Name ASC limit 1000]; } } APEX TEST CLASS @isTest private class testProjectSummaryPDFController { static testMethod void myUnitTest() { // make a valid Project__c record we will sent to PDF controller Project__c lvProject = makeValidProject(); // make a Sent_item__c record for the project Sent_item__c lvSentItemObj = makeSentItemObj(lvProject); // make a Received_item__c record for the project Received_item__c lvReceivedItemObj = makeReceivedItemObj(lvProject); // first get the standard controller for my object and pass in the Project obj ApexPages.StandardController lvStdCntrllr = new ApexPages.standardController(lvProject); // now create an instance of my controller ProjectSummaryPDFController controller = new ProjectSummaryPDFController(lvStdCntrllr); } static private Project__c makeValidProject() { // create Test Project record Project__c lvProj = new Project__c(); lvProj.Name = 'Name'; lvProj.Project_name__c = 'Project Name'; lvProj.Contractor__c = 'Contractor'; insert lvProj; return lvProj; } static private Sent_item__c makeSentItemObj(Project__c pProj) { Sent_Item__c lvObj = new Sent_Item__c(); lvObj.Name = 'Name'; lvObj.Description__c = 'Description'; lvObj.Project_Number__c = pProj.Id; insert lvObj; return lvObj; } static private Received_item__c makeReceivedItemObj(Project__c pProj) { Received_item__c lvObj = new Received_item__c(); lvObj.Name = 'Name'; lvObj.Description__c = 'Description'; lvObj.Project_Number__c = pProj.Id; insert lvObj; return lvObj; } }
I have resolved this issue. The issue was associated with the namespace