function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF7SF7 

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}"/>

</Apex:page>
 
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);
        reRend.setRedirect(true);
        return reRend;
    }

 
William TranWilliam Tran
Change this:

CF00N1300000BRJGg_lkid

to this:

CF00N1300000BRJGg

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. 

Thanks
SF7SF7
@william 

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.

thx.
SF7SF7
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
/a1k/e?CF00N1300000BRJGg=null&CF00N1300000BRJGg_lkid=a1j290000008P1dAAE&retUrl=a1j290000008P1dAAE

 
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:

Change

      Insert acct;

to 

     acct.Name ='Boohoo';
     Insert acct;

Thx