+ Start a Discussion

Custom Save method to redirect to child Edit page along with Parent ID

Hi ,

I have a Visual force page for creating a parent record in which i have a custom Save method and when save is clicked the  the page has to be redirected to the new page to create a child object and pb is i am unable to pull in the parent ID into the Child object page.
<apex:page standardController="Client_Discovery__c" Controller ="AddClientSite" sidebar="false">

<apex:commandButton value="Save" action="{!saveDiscovery}"/>

<apex:commandButton value="Cancel" action="{!cancel}"/>

public class AddClientSite {
    ApexPages.StandardController sc;
    public Client_Discovery__c acct{get;set;}

public PageReference saveAccount1(){
        Insert acct;
        PageReference reRend = new PageReference('/a1k/e?CF00N1300000BRJGg_lkid='+acct.id+'&retUrl=' + acct.Id);
        return reRend;

William TranWilliam Tran
Change this:


to this:


As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 


Hi , Thanks for the reply

When i change it i am getting a1j290000008P1JAAU in the lookUp field of the child .User-added image
William TranWilliam Tran
Yes, that's what you passed it. 

Try acct.Name instead of acct.id if you want the name to display.

William ,
I tried changing that and it is popluating null . I am sure there is some small error with the way i am writing this

PageReference reRend = new PageReference('/a1k/e?CF00N1300000BRJGg='+acct.Name+'&CF00N1300000BRJGg_lkid='+acct.id+'&retUrl=' + acct.Id);

Client Discovery  Name Name Auto Number   ( Acct.name should be this field auto number)

and even in the URL it poulates null

William TranWilliam Tran
did you ever set the name? 

public Client_Discovery__c acct{get;set;}

where did you set the name?

What are the attributes for Client_Discovery__c?

Try this:


      Insert acct;


     acct.Name ='Boohoo';
     Insert acct;