+ Start a Discussion
VenkateshVenkatesh 

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() 
    {
        System.debug(accountId);
        contact.AccountId = accountId;
        standardController.save();
        return null;
    }
}

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