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

parent id in related list

Hi all,

I have two objects A and B.A is master and B is detail object.In object A,I have a record, when I open that record and scroll down, in related list we have list of child objects and a new button.when I create a new child record from Object A  related list by clicking new button it will redirect to VF page.I have controller for this VF page.So my recruitment is to get the Object A record id to controller.Can any one help me .
Best Answer chosen by Venkatesh
Varun SinghVarun Singh
public class CreateContactExtensions 
    public String accountId { get; set; }
    public Contact contact { get; set; }
    ApexPages.StandardController standardController;

    public CreateContactExtensions(ApexPages.StandardController standardControllerParam) 
        accountId = 'test';
        standardController = standardControllerParam;
        contact = (Contact)standardController.getRecord(); 

    public String getAccountId()
        return accountId;

    public PageReference save() 
        contact.AccountId = accountId;;
        return null;

Here is a example suppose a as account and  b as Contact.
I Hope you can understand