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

How do you read the current page's data?

Error Message:


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Opportunity.Product__c

<apex:page standardController="Opportunity" extensions="workFlowData" id="oppsPage">
        <apex:form rendered="{!renderMe}">
        <apex:pageblock >
            <apex:selectList value="{!flows}" size="1">
                <apex:selectOptions value="{!WFNames}"/>
            <apex:actionSupport event="onchange" rerender="oppsPage" status="status"/>
        <apex:detail />


public class workFlowData {
    private final Opportunity opp;
    String[] flows = new String[]{};
    public workFlowData(ApexPages.StandardController stdController) {
        this.opp = (Opportunity)stdController.getRecord();
    public Opportunity getOpp() {
        return opp;
    public List<SelectOption> getWFNames() {
        List<Workflow__c> wf_names = [SELECT id, name FROM Workflow__c ORDER BY name];
        List<SelectOption> wf_dropdown= new List<SelectOption>();
        wf_dropdown.add(new SelectOption('',''));
        for (Workflow__c wf_name: wf_names) {
            wf_dropdown.add(new SelectOption(,;
        return wf_dropdown;
    public String[] getFlows() {
        return flows;
    public void setFlows(String[] flows) {
        this.flows = flows;
    public Boolean getRenderMe() {
        return opp.Product__c == null ;



Thanks for your help.




This error happens when you try to access a field of an object that wasn't include in the object query. In this case the error its related to the opportunity field Product__c. When you call to getRecord() method it doesn't query for this field, here is what salesforce documentation tells about getRecord method::


Returns the record that is currently in context, based on the value of the id query string parameter in the Visualforce page URL.


Note that only the fields that are referenced in the associated Visualforce markup are available for querying on this SObject. All other fields, including fields from any related objects, must be queried using a SOQL expression.


So, you need to add that field to the visualforce markup or either make your own SOQL Query instead of calling the getRecord() method