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

SObject row was retrieved via SOQL without querying
Hi,
I am working on Cloning cases. I am creating a custom button because we only want few fields to get cloned. I get this error when i click on the button clone
SObject row was retrieved via SOQL without querying the requested field: Case.Status
I am working on Cloning cases. I am creating a custom button because we only want few fields to get cloned. I get this error when i click on the button clone
SObject row was retrieved via SOQL without querying the requested field: Case.Status
Class: public class VFController { public case o {get;set;} public VFController(ApexPages.StandardController stdController) { this.o = (case)stdController.getRecord(); } // Code we will invoke on page load. public PageReference autoRun() { String theId = ApexPages.currentPage().getParameters().get('id'); if (theId == null) { // Display the Visualforce page's content if no Id is passed over return null; } List<Case> cases = [Select id,lot__c,status From Case ]; // Do all the dirty work we need the code to do // Redirect the user back to the original page PageReference pageRef = new PageReference('/' + theId); pageRef.setRedirect(true); return pageRef; } }
VF page: <apex:page standardController="Case" extensions="VFController"> <apex:form id="frmId"> <apex:pageBlock id="pb"> <apex:messages ></apex:messages> <apex:pageBlockSection columns="1" title="Clones Case" id="pbs_Clone"> <apex:InputField value="{!o.status}"/> <apex:InputField value="{!o.LOT__c}" required="true"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}" /> <apex:commandButton value="Cancel" action="{!Cancel}" /> </apex:pageBlockButtons> </apex:pageblock> </apex:form> </apex:page>
All Answers
You need to query the field for the bind variable you are using in the VF page which in this case is "o".
after this line
this.o = (case)stdController.getRecord();
do this
Case myCase=[Select id,lot__c,status From Case where id=:o.id];
and use myCase as the bind Variable.
go through below link .
https://developer.salesforce.com/docs/atlas.en-us.198.0.pages.meta/pages/apex_ApexPages_StandardController_getRecord.htm
http://bobbuzzard.blogspot.in/2011/04/dynamic-visualforce-bindings-and.html