+ Start a Discussion
Bhushan Singh 13Bhushan Singh 13 

while embedded VF page with custom object page layout that time VF field not showing

Hi,
while embedded VF page with custom object page layout that time VF fields are  not showing, in visulaforce page all fields are showing and i am able to save value also but after add that VF page in custom object page layout all fields are hidding. 
Please help me

Thanks & Regards
Bhushan Singh
Best Answer chosen by Bhushan Singh 13
GarryPGarryP
I think you might be receiving error on the page layout-
"SOQL fiedl was retrieved without querying."
I was able to see this error only and once this was resolved i was able to see the page inside layout.

see description/resolution below
/*here code is trying to access the RECORD. when this page is used in layout , getRecord does not return anything as the page is not parent page but it embedded in parent layout Hence controller is null. hence error
*/
  public ExampleController (ApexPages.StandardController Controller)
    {
        usr = (User__c)Controller.getRecord(); 
        this.controller=Controller;  
    } 
    
/*use GETID() method instead to capture the ID from the page, if this does not work you will have to tweak the code to get the record ID or check how you would like to initialize the page.
 */
public ExampleController (ApexPages.StandardController Controller)
    {
        usr.id = (ID)Controller.getID(); 
        this.controller=Controller;  
    }

 

All Answers

GarryPGarryP
can you please share the code of your VF page here?
Bhushan Singh 13Bhushan Singh 13
Hi Girish , 
Please find code 
VF Page 
<apex:page standardController="User__c" extensions="usercontroller"  sidebar="true">
<apex:sectionHeader title="User Edit" subtitle="New User" />
<!-- Begin Form -->
  <apex:form >
    <apex:pageBlock title="User Informations" mode="edit"> 

      <apex:pageBlockSection columns="2" showHeader="true" title="Information"> 
        <apex:inputField id="firstName" value="{!usr.First_Name__c}" required="false" />
        <apex:inputField id="lastName" value="{!usr.Last_Name__c}"  required="false" />     
        <apex:inputField id="email" value="{!usr.Email__c}"  required="true" />
      </apex:pageBlockSection>
       <apex:pageBlockButtons >

         <apex:commandButton value="Save" action="{!save}" rerender="error"/>           
       </apex:pageBlockButtons>
  </apex:pageBlock>
 
  </apex:form>

  
</apex:page>

Apex class

public class usercontroller {

    public User__c getUsr() {
        return usr;
    }

     
  
    public ApexPages.StandardController controller; 
    public User__c usr = new User__c();
    public Id id1 = usr.id;
    public String First_Name {get;set;}
    public String Last_Name {get;set;}
    public String Email {get;set;}
    
    public usercontroller() {

    }
    public usercontroller (ApexPages.StandardController Controller)
    {
        usr = (User__c)Controller.getRecord(); 
        this.controller=Controller;  
    } 
    
    public PageReference save() {
      insert usr; 
      PageReference nextPage = new PageReference(' https://ap2.salesforce.com/a01'+ usr.Id);
      //SObject record; // can be of any type
      //PageReference view = new ApexPages.standardController(record).view();
     
       
    return nextPage;
    }  
}

 
GarryPGarryP
I think you might be receiving error on the page layout-
"SOQL fiedl was retrieved without querying."
I was able to see this error only and once this was resolved i was able to see the page inside layout.

see description/resolution below
/*here code is trying to access the RECORD. when this page is used in layout , getRecord does not return anything as the page is not parent page but it embedded in parent layout Hence controller is null. hence error
*/
  public ExampleController (ApexPages.StandardController Controller)
    {
        usr = (User__c)Controller.getRecord(); 
        this.controller=Controller;  
    } 
    
/*use GETID() method instead to capture the ID from the page, if this does not work you will have to tweak the code to get the record ID or check how you would like to initialize the page.
 */
public ExampleController (ApexPages.StandardController Controller)
    {
        usr.id = (ID)Controller.getID(); 
        this.controller=Controller;  
    }

 
This was selected as the best answer
Bhushan Singh 13Bhushan Singh 13
Thanks Girish it is working for me.