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

How to capture Parent Record ID from the URL button to use it in the custom controller?

Hi all,


Parent : Agreement__c

Child : Agreement_line_item__c


I have a URL button on child as  /apex/MassInsertALI1?{!Agreement__c.Id}. 


I have to use this id to be captured and used through out the my custom controller and assign this id to the newly created child records. I know this can be done through the standard controller but the button is on the child related list on the parent page layout. 


Can you please help with this issue?


Thanks in advance 



Best Answer chosen by Admin (Salesforce Developers) 

try this



and in your controller get the Id from the below syntax


String parentId = Apexpages.currentPage().getParameters().get('id');