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
Bharatsingh Rajpali 6Bharatsingh Rajpali 6 

I have a Sales_office__c object and one of its record named as Big Bazar .....now I want to make a custom button which will redirect me to a visualfore page that will display id of big bazar page

How can I pass id of Big bazar record to my visualforce page via. Custom button
Best Answer chosen by Bharatsingh Rajpali 6
Rishab TyagiRishab Tyagi
Hello Bharatsingh,

You can add a merge field in the URL and then access that from the parameter in the VF page.

Eg: let's say that your VF page is display_id. Then you can use the following link in your custom button:

/display_id?tgtid={!Sales_office__c.Id}

After that if you have an apex controller in your VF page then you can use the following code to get the parameter in the controller:
 
ApexPages.currentPage().getParameters().get('tgtid');

Or if you want to directly access it in the VF page then you can use the following code:
 
{!$CurrentPage.Parameters.tgtId}

Hope that answers your question.
 

All Answers

Rishab TyagiRishab Tyagi
Hello Bharatsingh,

You can add a merge field in the URL and then access that from the parameter in the VF page.

Eg: let's say that your VF page is display_id. Then you can use the following link in your custom button:

/display_id?tgtid={!Sales_office__c.Id}

After that if you have an apex controller in your VF page then you can use the following code to get the parameter in the controller:
 
ApexPages.currentPage().getParameters().get('tgtid');

Or if you want to directly access it in the VF page then you can use the following code:
 
{!$CurrentPage.Parameters.tgtId}

Hope that answers your question.
 
This was selected as the best answer
Bharatsingh Rajpali 6Bharatsingh Rajpali 6
Thanks a lot it worked.....