My new related list button should redirect me to the New VF page for the child object, with certain fields from the Master on this form pre-filled. I can't seem to be able to both prefill the fields belonging to the Master or associate the new Child with the same Master. The VF page has a custom controller.

I tried using the format /apex/pageName?retURL=sameAsStdNewButton&lookupField_lkid={!Master__c.id}&MasterFieldToBePrefilledId1={!Master__c.Field__c}&... but it doesn't seem to work.

It would also be helpful if someone could tell me how to structure the saveURL.

2 Answers 2


If you are using a custom visualforce page in redirect URL then simply leverage parameters as given below:

New Button URL:


Actual link will be:


Now you can leverage parameter name "masterId" to fill in the Visualforce page input field.

If you are trying to redirect to a page which don;t have controller you can do it like:

New Button URL:


Actual link will be shown as:

  • Hi Ashwani. Thanks for your response, but this doesn't seem to work at all. I keep ending up with a completely new parent record and with the child linked to it. I want to be able to link to the existing parent.
    – Sandra Dee
    Jun 2, 2015 at 11:02
  • @SandraDee You may be using it different way. There is no way to insert a record having child linked automatically unit the parent exist. "masterId=a08200000148XpNAAU" or "CF00N20000007hitQ=ER-000722" are to reference parent record to a child record which your page will create.
    – Ashwani
    Jun 2, 2015 at 11:07

Hi you have to write a controller class from where you can assign field values to your child obj fields in constructor and then display them on vf page as prepopulated. Try writing in following code design:

public class className {

    ChildObj ch {get; set;}

    public className(ApexPages.StandardController con){
        MasterObj ms = [Select id,field1,feild2... from MasterObj where id = :ApexPages.currentPage().getParameters().get('masterId')];
        ch = new ChildObj();
        ch.field1 = ms.field1;
        ch.field2 = ms.field2;

/*****VF Page*****/
<apex:page standardcontroller="ChildObj" id="mypage" extensions="className">
    <apex:inputField value="{!ch.field1}"/>
    <apex:inputField value="{!ch.field2}"/>

/*****Button (URL)*****/

Hope this may help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .