I have two Visualforce Pages
, one for Account
and another for Opportunity
.
On the Account
page there is a button named New Opportunity
. I want to pre-populate some data from Account
fields to the Opportunity
page.
What I have done so far is I have created a button with the following url:
/apex/Oppurtunitynew?retURL=%2Fapex%2Faccountview%3Fid%3D{!Account.Id}%26sfdc.override%3D1%26core.apexpages.devmode.url%3D1&OIP87654543={!account.name}accid={!Account.Id}&sfdc.override=1
When I click on this button it redirects to the Opportunity
page (correct), but does not populate the fields (incorrect).
I have checked the redirecting URL which is
What I found it is not taking account id
after redirecting.
Best Answer
Based on the resulting url, your
{!account.Id}
value isnull
. This indicates the record has not yet been inserted. So the core problem has nothing to do with parameters, but rather order of operations. You should use acommandButton
that calls an action something like:Note that because your parameter names are all public, you can now reference them from your other controller/extension to make sure you get an exact match. Your markup would look something like: