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
Maf_007Maf_007 

Calling Visualforce page with standard controller from custom button

Hi All,

I have a visualforce page which overrides the new button for creating new record. It performs data validation and rerenders the page if something is wrong. I am trying to use same controller extension from a custom button as well. but when I add the visual force page in my button I get following error:

SObject row was retrieved via SOQL without querying the requested field:

A lot of people suggested to set rendered = false on the page but that does not meet my requirement as I need to get those fields in edit mode to perform similar action as I did when creating the record.

Any suggestions would be greatly appreciated.
Best Answer chosen by Maf_007
Pramod_SFDCPramod_SFDC
Hi,

So to get around this you can either do another query for the field in the controller , or better yet you can simply include a hidden reference to it on the VF page somewhere, something like:

Code:
<apex:outputText value="{!Condition__c.Criterion__c}" rendered="false"/>

The standard controller will pick it up when constructing your query and you will be free to reference it in your extension.


Regards
Pramod

All Answers

Pramod_SFDCPramod_SFDC
Hi,

So to get around this you can either do another query for the field in the controller , or better yet you can simply include a hidden reference to it on the VF page somewhere, something like:

Code:
<apex:outputText value="{!Condition__c.Criterion__c}" rendered="false"/>

The standard controller will pick it up when constructing your query and you will be free to reference it in your extension.


Regards
Pramod
This was selected as the best answer
Maf_007Maf_007
Hi Thanks for your reply, I have just queried all the fields from my extension and it's working fine
Pramod_SFDCPramod_SFDC
Hi,

My pleasure. Have a nice day !

Regards
Pramod