0

I've a one object Patient. To create patient, i've created VF page

(Account(lookup) & Region__c(picklist) are some field on this page);

now on Patient VF page i've one button "Save and Add opportunity".

when i click on "Save and Add opportunity" button the opportunity record creation standard page will open.

Now i've to auto populate two field(Account, Region__c) from previous vf page on opportunity record creation standard page. How can i do. Please Suggest.

VF page code line :

 <apex:commandButton value="Save And Add Opportunity" action="{!saveandCreateOppty}"/>

in controller i've used like:

public PageReference saveandCreateOppty(){
  PageReference pg = new PageReference('/006/e?retURL=/apex/ClientVisitReports_Edit_Wizard_Page2');
  pg.setRedirect(true);
  return pg;
}

Please suggest how to aut populate field from previous page on standard record creation page

0

Check helpful article on Salesforce URL Hacking to Prepopulate Fields on a Standard Page Layout by Ray Dehler.

You need to create a URL that will be open a standard opportunity new page.

The URL will be of the form, https://{org}/{object prepend}/e?{some ID field}={some value}&{some ID field}_lkid={some other ID field}&retURL=/{some third ID field}

Get the Salesforce Id of Account and Region__c fields and add these fields into the URL with their default values.

To get the Salesforce Id of field navigate to Setup => Create => Objects => Object Detail => Field Name, Retrieve the Id from URL

 public PageReference saveandCreateOppty(){
    PageReference pg = new PageReference('/006/e?retURL=%2F006%2Fo&[Account Field SF ID]=[Default Value]&[Region Field SF Id]=[Default Value]');
    pg.setRedirect(true);
    return pg;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.