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
kcnmaheshkcnmahesh 

Overriding new Button....Disply existing records while creating new record

Hi...,

 

My requirement is to display all existing records at the time of creating a new record.

 

Means  i need to override NEW button with visualforce page and i need to display all existing records with the help of controller.

 

I am not getting the logic .

 

can anyone help me on this requirement plz....?

Best Answer chosen by Admin (Salesforce Developers) 
Andy BoettcherAndy Boettcher

It looks like your GETer isn't public...

 

public with sharing class WhyAnalysisController {

    public WhyAnalysisController(ApexPages.StandardController controller) {

    }
    ** you need to make this public ** public List<Why_Why_Analysis__c> why {get;set;}

    public pageReference save(){
    
              return null;
}
    public pageReference query(){
    
        why = new List<Why_Why_Analysis__c>();
        why = [ select id , Fishbone_Analysis__c , Name from Why_Why_Analysis__c ];
        return null; 
}
}

 

All Answers

kcnmaheshkcnmahesh

Here is my code.....

 

 

VisualforcePage..

 

<apex:page standardController="Why_Why_Analysis__c" extensions="WhyAnalysisController" action="{!query}">
<apex:form >
<apex:pageBlock >
 <apex:pageBlockTable value="{!why}" var="a">
 <apex:outputField value="{!a.Fishbone_Analysis__c}">
 </apex:outputField>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:inputField value="{!Why_Why_Analysis__c.Fishbone_Analysis__c}"/>
<apex:inputField value="{!Why_Why_Analysis__c.Root_Cause__c}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

 

COntroller.....

 

public with sharing class WhyAnalysisController {

    public WhyAnalysisController(ApexPages.StandardController controller) {

    }
    List<Why_Why_Analysis__c> why {get;set;}
    public pageReference save(){
    
              return null;
}
    public pageReference query(){
    
        why = new List<Why_Why_Analysis__c>();
        why = [ select id , Fishbone_Analysis__c , Name from Why_Why_Analysis__c ];
        return null; 
}
}

 

 

But its showing Error message..

 

"Unknown Property why"

Andy BoettcherAndy Boettcher

It looks like your GETer isn't public...

 

public with sharing class WhyAnalysisController {

    public WhyAnalysisController(ApexPages.StandardController controller) {

    }
    ** you need to make this public ** public List<Why_Why_Analysis__c> why {get;set;}

    public pageReference save(){
    
              return null;
}
    public pageReference query(){
    
        why = new List<Why_Why_Analysis__c>();
        why = [ select id , Fishbone_Analysis__c , Name from Why_Why_Analysis__c ];
        return null; 
}
}

 

This was selected as the best answer
kcnmaheshkcnmahesh

Hi....,

 

Its working fine.

I deleted "With sharing" and i make that list as "public".

Thanks TECHMAN.