+ Start a Discussion
Mahima R 3Mahima R 3 

save button on account create page should navigate to contact create visual force page page with prepopulate account field

I Have 2 visualforce page, 
1-custom account create page with Save button(standard controller+ extention)
 2-custom contact create page
when i click on save button(on account page)  should navigate to contact create page. I have done that. but problem is Account field (in contact create page) should get prepopulated with account name.

How to do it? please help me out.
SARI4SARI4
Hi,

You can pass new Account id as parameter in the pagereference to Contact VF page.
Then on Contact VF page pull the account detail based on the account id and show them on VF page.
Below is sample.
 
public class contactController{
public string accId{get;set;}
public account acc {get;set;}
 public contactController(){
    accId= apexpages.currentpage().getparameters().get('AccountID');
    acc=[select name,phone from account where id=:accid];
  }
}


VF PAGE
<apex:page>
<apex:inputText value="{!acc.Name"/>
<apex:inputText value="{!acc.phone}"/>
</apex:page>
MARK IT AS BEST ANSWER, if it fix your issue