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
Alpesh Patel 16Alpesh Patel 16 

Pass reference of parent object on click of button located on related object

Hi Everyone,

I have a custom object A and related custom object B. I have put a button on related object B. When I press this button, I show a visualforce page that contains a grid of table data with checkboxes and a process button. Upon clicking this process button, I do some processing which requires data from the Parent Object A.
How can i pass data or reference of object A in the custom VF page of Object B and use it in cotroller class of object B.

Thanks.
Himanshu ParasharHimanshu Parashar
Hi Alpesh,

You can create a new list button on your child object and you can pass parent object id using following code. Lets say your parent object id is Invoice__c you can right following code
 
/apex/vfpagename?invoice_id={!Invoice__c.Id}

and on new vfpagename controller you can create object record
 
public class SampleClass{

     public SampleClass()
     {
           Invoice__c invoice= [select id,name from Invoice__c where  id=:ApexPages.currentPage().getParameters().get('invoice_id');

       }


}


Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer.