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
shan876shan876 

How to create an edit page?NEED HELP PLEASE

Hi all:
   My scenario:
              A user clicks on a new button that would take the necessary info from account record and place it into the edit page of the custom object filling in all the fields necessary from the Account record selected.
  1. Do I have to re-create the page in VF in edit mode ? If yes, then does anyone know how to create two columns and mock up the page directly the same as the edit page for that object???
  2. Can I link to the edit mode of the Page and do it that way?
  3. Does anyone have an example of this please...
Thanks
Scott.MScott.M
Hi,

Could you create a lookup relationship on the custom object and use formula fields to pull in the information from the account, then just use the new button in the related list for the custom object on the Account detail page?


RoadieRoadie

Here is some controller code that can get you there:

Code:
public PageReference redirectToNew() {
       CustomObj__c custObj = new CustomObj__c();
       //Pull data you want to use to pre-populate this new object...whatever you get can be
 //put in place of 'Initial value' entries here                   
       custObj.parameter1 = 'Initial value';
       custObj.parameter2 = 'Initial value2';
       insert custObj;   
       PageReference np = new PageReference('/' + custObj.id + 'e—retURL=%2F' + custObj.id);
       np.setRedirect(true);
       return np;
} 


 

shan876shan876
Hi Thanks for giving me that, How would the Visual Force Page mock up look like for this...Thanks
RoadieRoadie

VF page can be simple, I believe (didn't test this)...

<apex:page controller="yourController" tabStyle="Pipeline__c" action="{!redirectToNew}">

</apex:page>

...and, of course, to put this on a button, it would need to be an extension of a standard controller.

Potential issue with my previously suggested solution is that the record then exists (possibly too soon). If the user clicks cancel, then there's an empty record out there hanging out in the system. Good to handle that situation.

shan876shan876
Thank you so much for your help... One thing I wanted to know, is there a way to redirect the user to the edit page with every field filled in??
The redirection works, except I need the neccessary fields filled in before the user clicks save??