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
ShivaShiva 

Is it possible to know which button user clicked?

I am calling same VF page from two custom buttons(Ex: Button1 and Button2) from the detailed page. How do I know which button user clicked? I need to perform different task based on the button choice.

 

Thanks

 

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

rather than create a button to a VF page, you will create a button to a url, then you can add the param

 

so, the url looks something like this , it still calls the same visualforce page as you do now, just adds a param to the button

 

 

Button or Link URL    /apex/sendInvitations?vid={!Survey__c.Id}

 

 

All Answers

Ron HessRon Hess

Your buttons will have to pass a parameter to the page to allow the new page to know which is which

 

read up on < apex : param 

 

you can add a param to a button , which will then be visible to your controller.

ShivaShiva

Ron,

 

I am creating buttons by using "Custom Button or Link Edit" from custom object.

 

Steps:

 

1. Go to setup

2. Create objects.

3. Select a custom object

4. Scroll down to "custom buttons and links"

5. Click on new

6. On this page I am creating "Detail page button" (and linking to VF page)

7. Change the page layout to add the button this button.

 

But I don't see any parameter here to add.

 

Yes I do know if I create a button in my VF page I can pass parameter. This is not the button I am talking about.

Ron HessRon Hess

rather than create a button to a VF page, you will create a button to a url, then you can add the param

 

so, the url looks something like this , it still calls the same visualforce page as you do now, just adds a param to the button

 

 

Button or Link URL    /apex/sendInvitations?vid={!Survey__c.Id}

 

 

This was selected as the best answer
ShivaShiva
Thank you so much. It worked for me.