function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jReneejRenee 

Hi! How do I fix this error -- SObject row was retrieved via SOQL without querying the requested field: Opportunity.Opportunity_Contact__r

I get this error when I try to mass edit opportunity list views.  Does anyone have a solution for this?  I'm lost...
SwethaSwetha (Salesforce Developers) 
As mentioned in https://help.salesforce.com/s/articleView?id=000328927&type=1, 

The error 'SObject-row-was-retrieved-via-SOQL-without-querying-the-requested-field' can occur when accessing a Visualforce page with a standard controller and a custom controller extension. 

When a standard controller queries an object for a Visualforce page, it only retrieves the fields from the object that are referenced in the page. 
This improves efficiency by not retrieving fields that are not needed by the Visualforce page. 

When a custom controller references a field that is not included in the page, the field data is not available, and the error occurs. 

Two workarounds to resolve this issue are
> You can add a SOQL query to the custom controller that queries the missing fields 
> You can add a hidden reference to the field in the Visualforce page. 
For example: 
<apex:outputText value="{!Condition__c.Criterion__c}" rendered="false"/>

Related: https://salesforce.stackexchange.com/questions/106834/sobject-row-was-retrieved-via-soql-without-querying-the-requested-field-account


If this information helps, please mark the answer as best. Thank you